123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using UnityEngine;
- namespace RenderHeads.Media.AVProVideo
- {
- public partial class MediaPlayer : MonoBehaviour
- {
- #region Support for Time Scale
- #if AVPROVIDEO_BETA_SUPPORT_TIMESCALE
-
-
- private const float TimeScaleTimeoutMs = 20f;
- private bool _timeScaleIsControlling;
- private double _timeScaleVideoTime;
- private void UpdateTimeScale()
- {
- if (Time.timeScale != 1f || Time.captureFramerate != 0)
- {
- if (_controlInterface.IsPlaying())
- {
- _controlInterface.Pause();
- _timeScaleIsControlling = true;
- _timeScaleVideoTime = _controlInterface.GetCurrentTime();
- }
- if (_timeScaleIsControlling)
- {
-
- _timeScaleVideoTime += Time.deltaTime;
-
- if (_controlInterface.IsLooping() && _timeScaleVideoTime >= Info.GetDuration())
- {
-
- _timeScaleVideoTime = 0.0;
- }
- int preSeekFrameCount = TextureProducer.GetTextureFrameCount();
-
- {
- double preSeekTime = Control.GetCurrentTime();
-
- _controlInterface.Seek(_timeScaleVideoTime);
-
-
- if (Mathf.Approximately((float)preSeekTime, (float)_controlInterface.GetCurrentTime()))
- {
- return;
- }
- }
-
- if (!_controlInterface.WaitForNextFrame(GetDummyCamera(), preSeekFrameCount))
- {
-
- System.DateTime startTime = System.DateTime.Now;
- int lastFrameCount = TextureProducer.GetTextureFrameCount();
- while (_controlInterface != null && (System.DateTime.Now - startTime).TotalMilliseconds < (double)TimeScaleTimeoutMs)
- {
- _playerInterface.Update();
- _playerInterface.Render();
- GetDummyCamera().Render();
- if (lastFrameCount != TextureProducer.GetTextureFrameCount())
- {
- break;
- }
- }
- }
- }
- }
- else
- {
-
- if (_timeScaleIsControlling)
- {
- _controlInterface.Play();
- _timeScaleIsControlling = false;
- }
- }
- }
- #endif
- #endregion // Support for Time Scale
- }
- }
|