コード例 #1
0
        public VideoPlayerViewModel(DisplayVideoFrameDelegate displayVideoFrameCallback,
                                    VideoLib.VideoPlayer.DecodedVideoFormat decodedVideoFormat)
        {
            this.displayVideoFrameCallback = displayVideoFrameCallback;
            this.decodedVideoFormat        = decodedVideoFormat;

            videoDecoder = new VideoLib.VideoPlayer();
            videoDecoder.setLogCallback(videoDecoderLogCallback, true, true);

            audioPlayer = new AudioPlayer();

            videoRefreshTimer       = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE);
            videoRefreshTimer.Tick += new EventHandler(videoRefreshTimer_Tick);
            //videoRefreshTimer.SynchronizingObject = this;
            videoRefreshTimer.AutoReset = false;

            audioRefreshTimer           = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE);
            audioRefreshTimer.Tick     += new EventHandler(audioRefreshTimer_Tick);
            audioRefreshTimer.AutoReset = false;
            //audioRefreshTimer.SynchronizingObject = null;

            audioDiffAvgCoef = Math.Exp(Math.Log(0.01) / AUDIO_DIFF_AVG_NB);

            syncMode   = SyncMode.AUDIO_SYNCS_TO_VIDEO;
            VideoState = VideoState.CLOSED;

            playCommand  = new Command(new Action(() => startPlay()));
            pauseCommand = new Command(new Action(() => pausePlay()));
            closeCommand = new Command(new Action(() => close()));

            DurationSeconds = 0;
            PositionSeconds = 0;
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        public VideoPanelViewModel()
        {
            //
            //TODO: Add the constructor code here
            //
            //videoRender = null;
            //mediaPlayer.Dock = DockStyle.Fill;
            //mediaPlayer.stretchToFit = true;


            videoRender = new VideoRender(VideoPanel);
            audioPlayer = new StreamingAudioBuffer(this);

            //videoRender.initialize(0,0);
            videoDecoder = new VideoPlayer();
            videoDecoder.FrameQueue.Closed += new EventHandler(frameQueue_Closed);

            videoDecoder.setLogCallback(new VideoPlayer.LogCallbackDelegate(videoDecoderLogCallback),
                                        true, true);

            videoRefreshTimer       = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE);
            videoRefreshTimer.Tick += new EventHandler(videoRefreshTimer_Tick);
            //videoRefreshTimer.SynchronizingObject = this;
            videoRefreshTimer.AutoReset = false;

            audioRefreshTimer                     = HRTimerFactory.create(HRTimerFactory.TimerType.TIMER_QUEUE);
            audioRefreshTimer.Tick               += new EventHandler(audioRefreshTimer_Tick);
            audioRefreshTimer.AutoReset           = false;
            audioRefreshTimer.SynchronizingObject = null;

            videoDebug = new VideoDebugForm();

            audioDiffAvgCoef = Math.Exp(Math.Log(0.01) / AUDIO_DIFF_AVG_NB);

            //syncMode = SyncMode.VIDEO_SYNCS_TO_AUDIO;
            syncMode   = SyncMode.AUDIO_SYNCS_TO_VIDEO;
            VideoState = VideoState.CLOSED;

            updateTimeTrackBar = true;

            timeTrackBarToolTip           = new CustomToolTip();
            timeTrackBarToolTip.BackColor = SystemColors.Info;
            this.Controls.Add(timeTrackBarToolTip);

            timeTrackBarToolTip.Show();
            timeTrackBarToolTip.BringToFront();
            timeTrackBarToolTip.Visible = false;

            muteCheckBox.Checked = bool.Parse(Settings.getVar(Settings.VarName.VIDEO_MUTED));
            volumeTrackBar.Value = Util.lerp <int>(Double.Parse(Settings.getVar(Settings.VarName.VIDEO_VOLUME)), volumeTrackBar.Minimum, volumeTrackBar.Maximum);
        }