public VideoPlayerViewModel(Control owner, VideoLib.VideoPlayer.OutputPixelFormat decodedVideoFormat = VideoLib.VideoPlayer.OutputPixelFormat.YUV420P) { this.owner = owner; DecodedVideoFormat = decodedVideoFormat; videoDecoder = new VideoLib.VideoPlayer(); videoDecoder.FrameQueue.Finished += new EventHandler((s, e) => { owner.BeginInvoke(new Func <Task>(async() => await close())); }); videoDecoder.FrameQueue.IsBufferingChanged += new EventHandler((s, e) => { owner.BeginInvoke(new Action(() => { if (IsBufferingChanged != null) { IsBufferingChanged(this, videoDecoder.FrameQueue.IsBuffering); } })); }); audioPlayer = new AudioPlayer(owner); videoRender = new VideoRender(owner); audioDiffAvgCoef = Math.Exp(Math.Log(0.01) / AUDIO_DIFF_AVG_NB); //syncMode = SyncMode.AUDIO_SYNCS_TO_VIDEO; syncMode = SyncMode.VIDEO_SYNCS_TO_AUDIO; videoRefreshTimer = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE); videoRefreshTimer.Tick += new EventHandler(videoRefreshTimer_Tick); videoRefreshTimer.AutoReset = false; audioRefreshTimer = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE); audioRefreshTimer.Tick += new EventHandler(audioRefreshTimer_Tick); audioRefreshTimer.AutoReset = false; DurationSeconds = 0; PositionSeconds = 0; videoPts = 0; audioPts = 0; owner.HandleDestroyed += new EventHandler(async(s, e) => await close()); VideoState = VideoState.CLOSED; VideoLocation = ""; Subtitles = new Subtitles(Log); //interruptIOTokenSource = new CancellationTokenSource(); }
public VideoPlayerViewModel(Control owner, VideoLib.VideoPlayer.OutputPixelFormat decodedVideoFormat = VideoLib.VideoPlayer.OutputPixelFormat.YUV420P) { this.owner = owner; DecodedVideoFormat = decodedVideoFormat; videoDecoder = new VideoLib.VideoPlayer(); videoDecoder.FrameQueue.Finished += new EventHandler((s, e) => { owner.BeginInvoke(new Func<Task>(async () => await close())); }); videoDecoder.FrameQueue.IsBufferingChanged += new EventHandler((s, e) => { owner.BeginInvoke(new Action(() => { if (IsBufferingChanged != null) { IsBufferingChanged(this, videoDecoder.FrameQueue.IsBuffering); } })); }); audioPlayer = new AudioPlayer(owner); videoRender = new VideoRender(owner); audioDiffAvgCoef = Math.Exp(Math.Log(0.01) / AUDIO_DIFF_AVG_NB); //syncMode = SyncMode.AUDIO_SYNCS_TO_VIDEO; syncMode = SyncMode.VIDEO_SYNCS_TO_AUDIO; videoRefreshTimer = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE); videoRefreshTimer.Tick += new EventHandler(videoRefreshTimer_Tick); videoRefreshTimer.AutoReset = false; audioRefreshTimer = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE); audioRefreshTimer.Tick += new EventHandler(audioRefreshTimer_Tick); audioRefreshTimer.AutoReset = false; DurationSeconds = 0; PositionSeconds = 0; videoPts = 0; audioPts = 0; owner.HandleDestroyed += new EventHandler(async (s, e) => await close()); VideoState = VideoState.CLOSED; VideoLocation = ""; Subtitles = new Subtitles(Log); //interruptIOTokenSource = new CancellationTokenSource(); }