1
This commit is contained in:
69
Unity/Scripts/MediaPlayer/MediaPlayer.cs
Normal file
69
Unity/Scripts/MediaPlayer/MediaPlayer.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user