123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- using System;
- using UnityEngine;
- namespace RenderHeads.Media.AVProVideo
- {
- public sealed class NullMediaPlayer : BaseMediaPlayer
- {
- public override string GetVersion()
- {
- return "0.0.0";
- }
- public override bool OpenVideoFromFile(string path, long offset, string httpHeaderJson)
- {
- this._texture_AVPro = (Texture2D)Resources.Load("AVPro");
- this._texture_AVPro1 = (Texture2D)Resources.Load("AVPro1");
- if (this._texture_AVPro)
- {
- this._Width = this._texture_AVPro.width;
- this._height = this._texture_AVPro.height;
- }
- this._texture = this._texture_AVPro;
- this._fakeFlipTime = 0f;
- this._frameCount = 0;
- return true;
- }
- public override void CloseVideo()
- {
- this._frameCount = 0;
- Resources.UnloadAsset(this._texture_AVPro);
- Resources.UnloadAsset(this._texture_AVPro1);
- }
- public override void SetLooping(bool bLooping)
- {
- this._bLoop = bLooping;
- }
- public override bool IsLooping()
- {
- return this._bLoop;
- }
- public override bool HasMetaData()
- {
- return true;
- }
- public override bool CanPlay()
- {
- return true;
- }
- public override bool HasAudio()
- {
- return false;
- }
- public override bool HasVideo()
- {
- return false;
- }
- public override void Play()
- {
- this._isPlaying = true;
- this._isPaused = false;
- this._fakeFlipTime = 0f;
- }
- public override void Pause()
- {
- this._isPlaying = false;
- this._isPaused = true;
- }
- public override void Stop()
- {
- this._isPlaying = false;
- this._isPaused = false;
- }
- public override bool IsSeeking()
- {
- return false;
- }
- public override bool IsPlaying()
- {
- return this._isPlaying;
- }
- public override bool IsPaused()
- {
- return this._isPaused;
- }
- public override bool IsFinished()
- {
- return this._isPlaying && this._currentTime >= this.GetDurationMs();
- }
- public override bool IsBuffering()
- {
- return false;
- }
- public override float GetDurationMs()
- {
- return 10000f;
- }
- public override int GetVideoWidth()
- {
- return this._Width;
- }
- public override int GetVideoHeight()
- {
- return this._height;
- }
- public override float GetVideoDisplayRate()
- {
- return 10f;
- }
- public override Texture GetTexture(int index)
- {
- return this._texture;
- }
- public override int GetTextureFrameCount()
- {
- return this._frameCount;
- }
- public override bool RequiresVerticalFlip()
- {
- return false;
- }
- public override void Rewind()
- {
- this.Seek(0f);
- }
- public override void Seek(float timeMs)
- {
- this._currentTime = timeMs;
- }
- public override void SeekFast(float timeMs)
- {
- this._currentTime = timeMs;
- }
- public override float GetCurrentTimeMs()
- {
- return this._currentTime;
- }
- public override void SetPlaybackRate(float rate)
- {
- this._playbackRate = rate;
- }
- public override float GetPlaybackRate()
- {
- return this._playbackRate;
- }
- public override float GetBufferingProgress()
- {
- return 0f;
- }
- public override void MuteAudio(bool bMuted)
- {
- }
- public override bool IsMuted()
- {
- return true;
- }
- public override void SetVolume(float volume)
- {
- this._volume = volume;
- }
- public override float GetVolume()
- {
- return this._volume;
- }
- public override int GetAudioTrackCount()
- {
- return 0;
- }
- public override int GetCurrentAudioTrack()
- {
- return 0;
- }
- public override void SetAudioTrack(int index)
- {
- }
- public override int GetVideoTrackCount()
- {
- return 0;
- }
- public override int GetCurrentVideoTrack()
- {
- return 0;
- }
- public override string GetCurrentAudioTrackId()
- {
- return string.Empty;
- }
- public override int GetCurrentAudioTrackBitrate()
- {
- return 0;
- }
- public override void SetVideoTrack(int index)
- {
- }
- public override string GetCurrentVideoTrackId()
- {
- return string.Empty;
- }
- public override int GetCurrentVideoTrackBitrate()
- {
- return 0;
- }
- public override float GetVideoFrameRate()
- {
- return 0f;
- }
- public override void Update()
- {
- this.UpdateSubtitles();
- if (this._isPlaying)
- {
- this._currentTime += Time.deltaTime * 1000f;
- if (this._currentTime >= this.GetDurationMs())
- {
- this._currentTime = this.GetDurationMs();
- if (this._bLoop)
- {
- this.Rewind();
- }
- }
- this._fakeFlipTime += Time.deltaTime;
- if ((double)this._fakeFlipTime >= 0.1)
- {
- this._fakeFlipTime = 0f;
- this._texture = ((!(this._texture == this._texture_AVPro)) ? this._texture_AVPro : this._texture_AVPro1);
- this._frameCount++;
- }
- }
- }
- public override void Render()
- {
- }
- public override void Dispose()
- {
- }
- private bool _isPlaying;
- private bool _isPaused;
- private float _currentTime;
- private float _volume;
- private float _playbackRate = 1f;
- private bool _bLoop;
- private int _Width = 256;
- private int _height = 256;
- private Texture2D _texture;
- private Texture2D _texture_AVPro;
- private Texture2D _texture_AVPro1;
- private float _fakeFlipTime;
- private int _frameCount;
- private const float FrameRate = 10f;
- }
- }
|