コード例 #1
0
        /// <summary>
        /// Pauses the video
        /// </summary>
        public void Pause()
        {
            // End threads
            StoppingEvent.Set();

            // Stop the FilterGraph (but remembers the current position)
            DsError.ThrowExceptionForHR(FG_MediaControl.Stop());

            // Update VideoState
            currentState = VideoState.Paused;
        }
コード例 #2
0
        /// <summary>
        /// Stops playing the video
        /// </summary>
        public void Stop()
        {
            StoppingEvent.Set();

            // Stop the FilterGraph
            DsError.ThrowExceptionForHR(FG_MediaControl.Stop());

            // Reset the current position
            DsError.ThrowExceptionForHR(FG_MediaSeeking.SetPositions(0, AMSeekingSeekingFlags.AbsolutePositioning, 0, AMSeekingSeekingFlags.NoPositioning));

            // Update VideoState
            currentState = VideoState.Stopped;
        }
コード例 #3
0
        /// <summary>
        /// Starts playing the video
        /// </summary>
        public void Play()
        {
            if (currentState != VideoState.Playing)
            {
                StoppingEvent.Reset();

                // Create video threads
                ThreadPool.QueueUserWorkItem(new WaitCallback(UpdateBuffer));
                ThreadPool.QueueUserWorkItem(new WaitCallback(WaitForCompletion));

                // Start the FilterGraph
                DsError.ThrowExceptionForHR(FG_MediaControl.Run());

                // Update VideoState
                currentState = VideoState.Playing;
            }
        }
コード例 #4
0
 private void ReleaseInterface()
 {
     if (FG_MediaEventEx != null)
     {
         DsError.ThrowExceptionForHR(FG_MediaControl.Stop());
         //0x00008001 = WM_GRAPHNOTIFY
         DsError.ThrowExceptionForHR(FG_MediaEventEx.SetNotifyWindow(IntPtr.Zero, 0x00008001, IntPtr.Zero));
     }
     FG_MediaControl  = null;
     FG_MediaEventEx  = null;
     FG_GraphBuilder  = null;
     FG_MediaSeeking  = null;
     FG_MediaPosition = null;
     if (FG != null)
     {
         Marshal.ReleaseComObject(FG);
     }
     FG = null;
 }