Exemplo n.º 1
0
        public virtual bool SetPlaybackRate(double value)
        {
            if (_graphBuilder == null)
            {
                return(false);
            }
            IMediaSeeking mediaSeeking = _graphBuilder as IMediaSeeking;

            if (mediaSeeking == null)
            {
                return(false);
            }
            double currentRate;

            if (mediaSeeking.GetRate(out currentRate) == 0 && currentRate != value)
            {
                bool result = mediaSeeking.SetRate(value) == 0;
                if (result)
                {
                    FirePlaybackStateChanged();
                }
                return(result);
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Test Get/Set Rate
        /// </summary>
        void TestRate()
        {
            int    hr;
            double dRate1, dRate2;

            // Read the current play rate
            hr = m_ims.GetRate(out dRate1);
            Marshal.ThrowExceptionForHR(hr);

            // Change the rate
            hr = m_ims.SetRate(dRate1 + 1);
            Marshal.ThrowExceptionForHR(hr);

            // Re-read the rate
            hr = m_ims.GetRate(out dRate2);
            Marshal.ThrowExceptionForHR(hr);

            // See if we got the right answer
            Debug.Assert(dRate1 + 1 == dRate2, "Get/Set Rate");
        }
Exemplo n.º 3
0
        double IPlayer.GetRate()
        {
            double rate = 1.0;

            if (this.graphBuilder != null)
            {
                IMediaSeeking mediaSeeking = this.graphBuilder as IMediaSeeking;
                if (mediaSeeking != null)
                {
                    int hr = mediaSeeking.GetRate(out rate);
                }
            }
            return(rate);
        }
Exemplo n.º 4
0
        public virtual bool SetPlaybackRate(double value)
        {
            if (_graphBuilder == null || _ms == null)
            {
                return(false);
            }
            double currentRate;

            if (_ms.GetRate(out currentRate) == 0 && currentRate != value)
            {
                bool result = _ms.SetRate(value) == 0;
                if (result)
                {
                    FirePlaybackStateChanged();
                }
                return(result);
            }
            return(false);
        }
Exemplo n.º 5
0
        protected virtual HRESULT PreparePlayback()
        {
            m_MediaControl  = (IMediaControl)m_GraphBuilder;
            m_BasicVideo    = (IBasicVideo)m_GraphBuilder;
            m_MediaSeeking  = (IMediaSeeking)m_GraphBuilder;
            m_VideoWindow   = (IVideoWindow)m_GraphBuilder;
            m_MediaEventEx  = (IMediaEventEx)m_GraphBuilder;
            m_FrameStep     = (IVideoFrameStep)m_GraphBuilder;
            m_MediaPosition = (IMediaPosition)m_GraphBuilder;
            SettingUpVideoWindow();
            int hr = m_MediaEventEx.SetNotifyWindow(m_EventControl.Handle, WM_GRAPHNOTIFY, Marshal.GetIUnknownForObject(this));

            Debug.Assert(hr == 0);
            SetVolume(m_bMute ? -10000 : m_iVolume);
            if (m_dRate != 1.0)
            {
                m_MediaSeeking.SetRate(m_dRate);
                m_MediaSeeking.GetRate(out m_dRate);
            }
            OnPlaybackReady?.Invoke(this, EventArgs.Empty);
            return((HRESULT)hr);
        }
Exemplo n.º 6
0
        private void loadVideo(String videoPath)
        {
            videoFilepath = videoPath;
                videoFileName.Text = getDisplayVideoName();

                if (graph != null)
                {
                    graph = null;

                }
                if (mediaControl != null)
                {
                    // Stop media playback
                    this.mediaControl.Stop();
                    mediaControl = null;
                }

                if (videoWindow != null)
                {
                    videoWindow.put_Owner(IntPtr.Zero);
                    videoWindow = null;
                }

                if (mediaSeeking != null)
                {

                    mediaSeeking = null;
                }
                if (basicAudio != null)
                {

                    basicAudio = null;
                }
                GC.Collect();

               /* if (mediaPosition != null)
                {
                    mediaPosition = null;
                }*/

                graph = (IGraphBuilder)new FilterGraph();
                mediaControl = (IMediaControl)graph;
                //mediaPosition = (IMediaPosition)graph;
                videoWindow = (IVideoWindow)graph;
                mediaSeeking = (IMediaSeeking)graph;
                basicAudio = (IBasicAudio)graph;

                AviSplitter spliter = new AviSplitter();
                graph.AddFilter((IBaseFilter)spliter, null);
                graph.RenderFile(videoPath, null);
                graph.SetDefaultSyncSource();

                /*
                 * AMSeekingSeekingCapabilities cap = AMSeekingSeekingCapabilities.CanGetCurrentPos;
                if (mediaSeeking.CheckCapabilities(ref cap) > 0)
                {
                    this.consoleErreur.AppendText("Impossible de recuperer la position de la frame");
                }
                 * */

                videoWindow.put_Owner(videoPanel.Handle);

                videoWindow.put_MessageDrain(videoPanel.Handle);

                videoWindow.put_WindowStyle(WindowStyle.Child);
                videoWindow.put_WindowStyleEx(WindowStyleEx.ControlParent);
                videoWindow.put_Left(0);
                videoWindow.put_Top(0);
                videoWindow.put_Width(videoPanel.Width);
                videoWindow.put_Height(videoPanel.Height);

                //positionTrackbar.Enabled = true;
                speedTrackBar.Enabled = true;
                mediaSeeking.SetTimeFormat(TimeFormat.Frame);

                double rate;
                mediaSeeking.GetRate(out rate);
                rateText.Text = rate.ToString();
                speedTrackBar.Value = (int)(speedTrackBar.Maximum * rate / 2);

                trackBar1.Value = trackBar1.Maximum / 2;
                this.basicAudio.put_Volume(-5000 + 5000 * trackBar1.Value / trackBar1.Maximum);
            //mediaPosition.put_Rate(0.5);
                running = false;
                frameChanged = false;
        }
Exemplo n.º 7
0
 protected virtual HRESULT PreparePlayback()
 {
     m_MediaControl = (IMediaControl)m_GraphBuilder;
     m_BasicVideo = (IBasicVideo)m_GraphBuilder;
     m_MediaSeeking = (IMediaSeeking)m_GraphBuilder;
     m_VideoWindow = (IVideoWindow)m_GraphBuilder;
     m_MediaEventEx = (IMediaEventEx)m_GraphBuilder;
     m_FrameStep = (IVideoFrameStep)m_GraphBuilder;
     SettingUpVideoWindow();
     int hr = m_MediaEventEx.SetNotifyWindow(m_EventControl.Handle, WM_GRAPHNOTIFY, Marshal.GetIUnknownForObject(this));
     Debug.Assert(hr == 0);
     SetVolume(m_bMute ? -10000 : m_iVolume);
     if (m_dRate != 1.0)
     {
         m_MediaSeeking.SetRate(m_dRate);
         m_MediaSeeking.GetRate(out m_dRate);
     }
     if (OnPlaybackReady != null) OnPlaybackReady(this, EventArgs.Empty);
     return (HRESULT)hr;
 }