private void SeekToPosition(long time) { var target = TimeSpan.FromMilliseconds(time); if (target.TotalMilliseconds < 0) { target = TimeSpan.Zero; } VideoElement.Seek(target).GetAwaiter().GetResult(); Position.Time = (long)target.TotalMilliseconds; }
public void JumpDuration(long duration) { var target = VideoElement.Position + TimeSpan.FromMilliseconds(duration); if (target.TotalMilliseconds < 0) { target = TimeSpan.Zero; } VideoElement.Seek(target).GetAwaiter().GetResult(); Position.Time = (long)target.TotalMilliseconds; }
public PlaybackView() { InitializeComponent(); VideoElement.PositionChanged += (o, args) => Position.Time = (long)args.Position.TotalMilliseconds; VideoElement.MediaOpened += (o, args) => Position.Total = (long)args.Info.Duration.TotalMilliseconds; VideoElement.MediaFailed += (o, args) => Console.WriteLine(@"[FFME] MediaFailed : " + args.ErrorException); VideoElement.MediaEnded += async(o, args) => { await VideoElement.Seek(TimeSpan.Zero); await VideoElement.Play(); }; //VideoElement.RenderingVideo += RenderPreviewOnVideo; Position.OnPositionActiveChanged += () => SeekToPosition(Position.Time); }