69 lines
1.5 KiB
C#
69 lines
1.5 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.Events;
|
||
|
using BITKit;
|
||
|
using UnityEngine.Video;
|
||
|
namespace BITKit.Media
|
||
|
{
|
||
|
public abstract class MediaPlayer<TPlayer> : Provider
|
||
|
{
|
||
|
[Header(Constant.Header.Settings)]
|
||
|
public bool playOnStart;
|
||
|
[Header(Constant.Header.State)]
|
||
|
public bool isPlaying;
|
||
|
public float currentTime;
|
||
|
[Header(Constant.Header.Components)]
|
||
|
public TPlayer player;
|
||
|
[Header(Constant.Header.Events)]
|
||
|
public UnityEvent onStartPlay = new();
|
||
|
public UnityEvent onStopPlay = new();
|
||
|
public UnityEvent onPlay = new();
|
||
|
public UnityEvent onPause = new();
|
||
|
public UnityEvent<float> onSetTotalTime;
|
||
|
public UnityEvent<string> onSetTotalTimeAsString;
|
||
|
public UnityEvent<float> onTime;
|
||
|
public UnityEvent<string> onTimeAsString;
|
||
|
|
||
|
protected virtual void OnStart()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public virtual void Play()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public virtual void Stop()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public virtual void PlayOrPause()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
public virtual void UpdateProgess()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public virtual void SetNormalizeTime(float time)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
void Start()
|
||
|
{
|
||
|
OnStart();
|
||
|
if (playOnStart)
|
||
|
{
|
||
|
Play();
|
||
|
}
|
||
|
}
|
||
|
void Update()
|
||
|
{
|
||
|
if (isPlaying)
|
||
|
{
|
||
|
UpdateProgess();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|