Example #1
0
        public int StepFrames(int nFramesToStep)
        {
            int hr = 0;

            // If the Frame Stepping interface exists, use it to step frames
            if (frameStep != null)
            {
                // The renderer may not support frame stepping for more than one
                // frame at a time, so check for support.  S_OK indicates that the
                // renderer can step nFramesToStep successfully.
                hr = frameStep.CanStep(nFramesToStep, null);
                if (hr == 0)
                {
                    // The graph must be paused for frame stepping to work
                    if (currentState != PlayState.Paused)
                    {
                        PauseClip();
                    }

                    // Step the requested number of frames, if supported
                    hr = frameStep.Step(nFramesToStep, null);
                }
            }
            return(hr);
        }
Example #2
0
        //
        //Method to start to play a media file
        //
        private void LoadFile(string fName)
        {
            try
            {
                //get the graph filter ready to render
                graphBuilder.RenderFile(fName, null);

                //set the trackbar
                OABool bCsf, bCsb;
                mediaPos.CanSeekBackward(out bCsb);
                mediaPos.CanSeekForward(out bCsf);
                isSeeking = (bCsb == OABool.True) && (bCsf == OABool.True);
                if (isSeeking)
                {
                    trackBar1.Enabled = true;
                }
                else
                {
                    trackBar1.Enabled = false;
                }
                trackBar1.Minimum = 0;

                double duration;
                mediaPos.get_Duration(out duration);
                trackBar1.Maximum = (int)(duration * 100.0);
                Text = fName;

                //check for the ability to step
                frameStep = graphBuilder as IVideoFrameStep;
                if (frameStep.CanStep(1, null) == 0)
                {
                    canStep = true;
                    buttonFramestep.Enabled = true;
                }

                //prepare and set the video window
                videoWin = graphBuilder as IVideoWindow;
                videoWin.put_Owner((IntPtr)panel1.Handle);
                videoWin.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
                Rectangle rc = panel1.ClientRectangle;
                videoWin.SetWindowPosition(0, 0, rc.Right, rc.Bottom);
                mediaEvt.SetNotifyWindow((IntPtr)this.Handle, WM_GRAPHNOTIFY, (IntPtr)0);

                //set the different values for controls
                trackBar1.Value           = 0;
                minutes                   = (int)duration / 60;
                seconds                   = (int)duration % 60;
                statusBar1.Panels[0].Text = "Duration: " + minutes.ToString("D2")
                                            + ":m" + seconds.ToString("D2") + ":s";
                graphState = State.Playing;

                this.buttonPlay.Text = "Pause";
                //start the playback
                mediaCtrl.Run();
            }
            catch (Exception) { Text = "Error loading file"; }
        }
Example #3
0
        /// <summary>
        /// step the frames
        /// </summary>
        public void StepFrame(int framecount)
        {
            int i = frameStep.CanStep(0, null);

            if (i == 0)
            {
                this.Play();
                frameStep.Step(framecount, null);
                this.PlayerState = PlayerState.SteppingFrames;
            }
        }
Example #4
0
        /// <summary>
        /// The get frame step interface.
        /// Some video renderers support stepping media frame by frame with the
        /// IVideoFrameStep interface.  See the interface documentation for more
        /// details on frame stepping.
        /// </summary>
        /// <returns> True, if frame step interface is available, otherwise false </returns>
        private bool GetFrameStepInterface()
        {
            int hr = 0;

            IVideoFrameStep frameStepTest = null;

            // Get the frame step interface, if supported
            frameStepTest = (IVideoFrameStep)this.filterGraph;

            // Check if this decoder can step
            hr = frameStepTest.CanStep(0, null);
            if (hr == 0)
            {
                this.frameStep = frameStepTest;
                return(true);
            }

            this.frameStep = null;
            return(false);
        }
Example #5
0
        // Some video renderers support stepping media frame by frame with the
        // IVideoFrameStep interface.  See the interface documentation for more
        // details on frame stepping.
        private bool GetFrameStepInterface()
        {
            int hr = 0;

            // Get the frame step interface, if supported
            IVideoFrameStep frameStepTest = this.graphBuilder as IVideoFrameStep;

            // Check if this decoder can step
            hr = frameStepTest.CanStep(0, null);
            if (hr == 0)
            {
                this.frameStep = frameStepTest;
                return(true);
            }
            else
            {
                this.frameStep = null;
                return(false);
            }
        }
Example #6
0
        /// Some video renderers support stepping media frame by frame with the
        /// IVideoFrameStep interface.  See the interface documentation for more
        /// details on frame stepping.
        public bool GetFrameStepInterface()
        {
            int             hr            = 0;
            IVideoFrameStep frameStepTest = null;

            // Get the frame step interface, if supported
            frameStepTest = (IVideoFrameStep)graphBuilder;

            // Check if this decoder can step
            hr = frameStepTest.CanStep(0, null);
            if (hr == 0)
            {
                frameStep = frameStepTest;
                return(true);
            }
            else
            {
                frameStep = null;
                return(false);
            }
        }
Example #7
0
        //
        // Some video renderers support stepping media frame by frame with the
        // IVideoFrameStep interface.  See the interface documentation for more
        // details on frame stepping.
        //
        private bool GetFrameStepInterface()
        {
            int hr = 0;

            IVideoFrameStep frameStepTest = null;

            // Get the frame step interface, if supported
            frameStepTest = (IVideoFrameStep)this.graphBuilder;

            // Check if this decoder can step
            hr = frameStepTest.CanStep(0, null);
            if (hr == 0)
            {
                this.frameStep = frameStepTest;
                return(true);
            }
            else
            {
                // BUG 1560263 found by husakm (thanks)...
                // Marshal.ReleaseComObject(frameStepTest);
                this.frameStep = null;
                return(false);
            }
        }
Example #8
0
        //
        // Some video renderers support stepping media frame by frame with the
        // IVideoFrameStep interface.  See the interface documentation for more
        // details on frame stepping.
        //
        private bool GetFrameStepInterface()
        {
            // Get the frame step interface, if supported
            IVideoFrameStep frameStepTest = this.graphBuilder as IVideoFrameStep;

            if (frameStepTest == null)
            {
                SetLastError("Frame Step interface could be get");
                return(false);
            }

            // Check if this decoder can step
            if (Check(frameStepTest.CanStep(0, null)))
            {
                this.frameStep = frameStepTest;
                return(true);
            }
            else
            {
                Marshal.ReleaseComObject(frameStepTest);
                frameStepTest = null;
                return(false);
            }
        }
Example #9
0
        /// <summary> detect if we can single step. </summary>
        bool GetFrameStepInterface()
        {
            videoStep = graphBuilder as IVideoFrameStep;
            if( videoStep == null )
            {
                return false;
            }

            // Check if this decoder can step
            int hr = videoStep.CanStep( 0, null );
            if( hr != 0 )
            {
                videoStep = null;
                return false;
            }
            return true;
        }