video playback speed control
							parent
							
								
									3966a0c4ea
								
							
						
					
					
						commit
						ad0c86e8f6
					
				|  | @ -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( | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue