diff --git a/src/Video/Video.cs b/src/Video/Video.cs index 9dacfe2..f2df5ad 100644 --- a/src/Video/Video.cs +++ b/src/Video/Video.cs @@ -17,9 +17,9 @@ namespace MoonWorks.Video { private IntPtr Handle; - public bool Loop { get; set; } - public bool Mute { get; set; } - public float Volume { get; set; } + public bool Loop { get; private set; } + public float Volume { get; private set; } + public float PlaybackSpeed { get; set; } public double FramesPerSecond => fps; private VideoState State = VideoState.Stopped; @@ -41,6 +41,8 @@ namespace MoonWorks.Video private Sampler LinearSampler; private Stopwatch timer; + private double lastTimestamp; + private double timeElapsed; private bool disposed; @@ -173,6 +175,8 @@ namespace MoonWorks.Video timer.Reset(); Theorafile.tf_reset(Handle); + lastTimestamp = 0; + timeElapsed = 0; State = VideoState.Stopped; } @@ -189,7 +193,10 @@ namespace MoonWorks.Video return RenderTexture; } - int thisFrame = (int) (timer.Elapsed.TotalMilliseconds / (1000.0 / FramesPerSecond)); + timeElapsed += (timer.Elapsed.TotalMilliseconds - lastTimestamp) * PlaybackSpeed; + lastTimestamp = timer.Elapsed.TotalMilliseconds; + + int thisFrame = ((int) (timeElapsed / (1000.0 / FramesPerSecond))); if (thisFrame > currentFrame) { if (Theorafile.tf_readvideo(