• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IVideoWindow类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IVideoWindow的典型用法代码示例。如果您正苦于以下问题:C# IVideoWindow类的具体用法?C# IVideoWindow怎么用?C# IVideoWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IVideoWindow类属于命名空间,在下文中一共展示了IVideoWindow类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PlayerCore

        public PlayerCore(string file)
        {
            graphBuilder = (new FilterGraph()) as IFilterGraph2;
            if (graphBuilder == null) return;
            mediaControl = graphBuilder as IMediaControl;
            mediaSeeking = graphBuilder as IMediaSeeking;
            audioControl = graphBuilder as IBasicAudio;
            if (mediaControl == null || mediaSeeking == null || audioControl == null) return;
            //int hr = mediaControl.RenderFile(file);
            FileInfo info = new FileInfo(file);
            ISupport support = Supports.Instance[info.Extension];
            int hr = -1;
            if (support != null)
                hr = support.RenderGraph(graphBuilder, file);
            else
                hr = mediaControl.RenderFile(file);

            fileName = file;
            if (hr != 0) errorStack.Push(hr);
            if (hr != 0) return;
            mediaSeeking.SetTimeFormat(TimeFormat.MediaTime);
            isValidate = true;
            window = graphBuilder as IVideoWindow;
            if (window != null)
            {
                int width = 0;
                int height = 0;
                window.get_Width(out width);
                window.get_Height(out height);
                nativeSize = new Size(width, height);
            }
        }
开发者ID:crazyender,项目名称:Console-Player,代码行数:32,代码来源:core.cs


示例2: Motor

        public Motor(AnaPencere anapencere)
        {
            this.anaPencere = anapencere;
            this.bulunmaDurumu = false; // bulunma durumu(çevrimiçi,meþgul vs.) ayarlanmadý
            this.kayitDurumu = RTC_REGISTRATION_STATE.RTCRS_NOT_REGISTERED; // Henüz kayýt olmadýk
            htPencereler = new Hashtable(); // uri key leri ile pencereler takip edilir
            Oturumlar = new ArrayList(); // açýlan oturumlarla(sessionEvent.Sessison) oturumlar takip edilir
            try
            {
                istemci = new RTCClientClass();
                istemci.Initialize();
                istemci.EventFilter = Sabitler.RTC_EVENTFILTERS;
                istemci.ListenForIncomingSessions = RTC_LISTEN_MODE.RTCLM_BOTH; // Gelen mesajlarý dinle, SIP portunu açar(5060)
                istemci.IRTCEventNotification_Event_Event += new IRTCEventNotification_EventEventHandler(istemci_IRTCEventNotification_Event_Event);

                istemci.SetPreferredMediaTypes(Sabitler.RTC_MEDIA_SABITLERI, true);
                gelenMedia = istemci.get_IVideoWindow(RTC_VIDEO_DEVICE.RTCVD_RECEIVE);
                gidenMedia = istemci.get_IVideoWindow(RTC_VIDEO_DEVICE.RTCVD_PREVIEW);
                istemci.ClientName = "RTCClient";
                istemci.ClientCurVer = "1.0";
            }
            catch(COMException hata)
            {
                this.anaPencere.MesajGoster(hata.ToString(), "Hata");
            }
        }
开发者ID:ugurcicekfidan,项目名称:VisualStudioWorks,代码行数:26,代码来源:Motor.cs


示例3: PlayCinematic

        // Starts playing a new cinematic
        public void PlayCinematic(string file, int x, int y, int w, int h)
        {
            // Lame bugfix: DirectShow and Fullscreen doesnt like eachother
            if (CVars.Instance.Get("r_fs", "0", CVarFlags.ARCHIVE).Integer == 1)
            {
                if (AlterGameState)
                {
                    playing = true;
                    StopCinematic();
                }
                return;
            }

            // Check if file exists
            if (FileCache.Instance.Contains(file))
                file = FileCache.Instance.GetFile(file).FullName;
            else
            {
                if (AlterGameState)
                {
                    playing = true;
                    StopCinematic();
                }
                Common.Instance.WriteLine("PlayCinematic: Could not find video: {0}", file);
                return;
            }

            // Have the graph builder construct its the appropriate graph automatically
            this.graphBuilder = (IGraphBuilder)new FilterGraph();
            int hr = graphBuilder.RenderFile(file, null);
            DsError.ThrowExceptionForHR(hr);

            mediaControl = (IMediaControl)this.graphBuilder;
            mediaEventEx = (IMediaEventEx)this.graphBuilder;
            videoWindow = this.graphBuilder as IVideoWindow;
            basicVideo = this.graphBuilder as IBasicVideo;

            // Setup the video window
            hr = this.videoWindow.put_Owner(Renderer.Instance.form.Handle);
            DsError.ThrowExceptionForHR(hr);
            hr = this.videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
            DsError.ThrowExceptionForHR(hr);

            // Set the video size
            //int lWidth, lHeight;
            //hr = this.basicVideo.GetVideoSize(out lWidth, out lHeight);
            hr = this.videoWindow.SetWindowPosition(x, y, w, h);
            videoWindow.put_FullScreenMode((CVars.Instance.Get("r_fs", "0", CVarFlags.ARCHIVE).Integer == 1) ? OABool.True : OABool.False);
            DsError.ThrowExceptionForHR(hr);

            // Run the graph to play the media file
            hr = this.mediaControl.Run();
            DsError.ThrowExceptionForHR(hr);
            playing = true;
            if (AlterGameState)
                Client.Instance.state = CubeHags.common.ConnectState.CINEMATIC;
            Common.Instance.WriteLine("Playing cinematic: {0}", file);

            EventCode code;
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:61,代码来源:Cinematic.cs


示例4: ShowMedia

        /// <summary>
        /// Plays the given mediafile in the internal mediaplayer
        /// </summary>
        /// <param name="FilePath">File to play</param>
        public void ShowMedia(string FilePath)
        {
            StopMedia();
            Lbl_CurrentMedia.Text = Path.GetFileName(FilePath);
            m_objFilterGraph = new FilgraphManager();
            m_objFilterGraph.RenderFile(FilePath);

            m_objBasicAudio = m_objFilterGraph as IBasicAudio;

            try
            {
                m_objVideoWindow = m_objFilterGraph as IVideoWindow;
                m_objVideoWindow.Owner = (int)panel2.Handle;
                //m_objVideoWindow.Owner = (int)panel1.Handle;

                m_objVideoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
                m_objVideoWindow.SetWindowPosition(panel2.ClientRectangle.Left,
                   panel2.ClientRectangle.Top,
                    panel2.ClientRectangle.Width,
                    panel2.ClientRectangle.Height);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                m_objVideoWindow = null;
            }

            m_objMediaEvent = m_objFilterGraph as IMediaEvent;

            m_objMediaEventEx = m_objFilterGraph as IMediaEventEx;
            m_objMediaEventEx.SetNotifyWindow((int)this.Handle, WM_GRAPHNOTIFY, 0);

            m_objMediaPosition = m_objFilterGraph as IMediaPosition;

            m_objMediaControl = m_objFilterGraph as IMediaControl;

            m_objMediaControl.Run();
            m_CurrentStatus = MediaStatus.Running;
            UpdateMediaButtons();

            //UpdateStatusBar();
            //UpdateToolBar();
        }
开发者ID:szopenfx,项目名称:code,代码行数:47,代码来源:GraphicalInterface2.cs


示例5: cmdOpen_Click

        private void cmdOpen_Click(object sender, EventArgs e)
        {
            // Allow the user to choose a file.
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;*.wav;*.mp2;*.mp3|All Files|*.*";
            
            if (DialogResult.OK == openFileDialog.ShowDialog())
            {
                // Stop the playback for the current movie, if it exists.
                if (mc != null) mc.Stop();
                mc = null;
                videoWindow = null;

                // Load the movie file.
                FilgraphManager graphManager = new FilgraphManager();
                graphManager.RenderFile(openFileDialog.FileName);

                // Attach the view to a picture box on the form.
                try
                {
                    videoWindow = (IVideoWindow)graphManager;
                    videoWindow.Owner = (int)pictureBox1.Handle;
                    videoWindow.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
                    videoWindow.SetWindowPosition(pictureBox1.ClientRectangle.Left,
                        pictureBox1.ClientRectangle.Top,
                        pictureBox1.ClientRectangle.Width,
                        pictureBox1.ClientRectangle.Height);
                }
                catch
                {
                    // An error can occur if the file does not have a vide
                    // source (for example, an MP3 file.)
                    // You can ignore this error and still allow playback to
                    // continue (without any visualization).
                }

                // Start the playback (asynchronously).
                mc = (IMediaControl)graphManager;
                mc.Run();
            }
        }
开发者ID:ehershey,项目名称:development,代码行数:41,代码来源:MoviePlayer.cs


示例6: Initialize

        public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            const int wsChild = 0x40000000;

            string ext = System.IO.Path.GetExtension(videoFileName).ToLower();
            bool isAudio = ext == ".mp3" || ext == ".wav" || ext == ".wma" || ext == ".ogg" || ext == ".mpa" || ext == ".m4a" || ext == ".ape" || ext == ".aiff" || ext == ".flac" || ext == ".acc" || ext == ".mka";

            OnVideoLoaded = onVideoLoaded;
            OnVideoEnded = onVideoEnded;

            VideoFileName = videoFileName;
            _owner = ownerControl;
            _quartzFilgraphManager = new FilgraphManager();
            _quartzFilgraphManager.RenderFile(VideoFileName);

            if (!isAudio)
            {
                _quartzVideo = _quartzFilgraphManager as IVideoWindow;
                _quartzVideo.Owner = (int)ownerControl.Handle;
                _quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height);
                _quartzVideo.WindowStyle = wsChild;
            }
            //Play();

            if (!isAudio)
                (_quartzFilgraphManager as IBasicVideo).GetVideoSize(out _sourceWidth, out _sourceHeight);

            _owner.Resize += OwnerControlResize;
            _mediaPosition = (IMediaPosition)_quartzFilgraphManager;
            if (OnVideoLoaded != null)
            {
                _videoLoader = new BackgroundWorker();
                _videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted;
                _videoLoader.DoWork += VideoLoaderDoWork;
                _videoLoader.RunWorkerAsync();
            }

            OwnerControlResize(this, null);
            _videoEndTimer = new Timer { Interval = 500 };
            _videoEndTimer.Tick += VideoEndTimerTick;
            _videoEndTimer.Start();

            if (!isAudio)
                _quartzVideo.MessageDrain = (int)ownerControl.Handle;
        }
开发者ID:ItsJustSean,项目名称:subtitleedit,代码行数:45,代码来源:QuartsPlayer.cs


示例7: Cleanup

    private void Cleanup()
    {
      if (graphBuilder == null)
      {
        return;
      }
      int hr;
      Log.Info("RTSPPlayer:cleanup DShow graph");
      try
      {
        if (VMR9Util.g_vmr9 != null)
        {
          VMR9Util.g_vmr9.Vmr9MediaCtrl(_mediaCtrl);
          VMR9Util.g_vmr9.Enable(false);
        }

        if (mediaEvt != null)
        {
          hr = mediaEvt.SetNotifyWindow(IntPtr.Zero, WM_GRAPHNOTIFY, IntPtr.Zero);
        }

        videoWin = graphBuilder as IVideoWindow;
        if (videoWin != null && GUIGraphicsContext.VideoRenderer != GUIGraphicsContext.VideoRendererType.madVR)
        {
          videoWin.put_Owner(IntPtr.Zero);
          videoWin.put_Visible(OABool.False);
        }

        _mediaCtrl = null;
        mediaEvt = null;
        _mediaSeeking = null;
        mediaPos = null;
        basicAudio = null;
        basicVideo = null;
        videoWin = null;
        SubEngine.GetInstance().FreeSubtitles();

        if (graphBuilder != null)
        {
          DirectShowUtil.RemoveFilters(graphBuilder);
          if (_rotEntry != null)
          {
            _rotEntry.SafeDispose();
            _rotEntry = null;
          }
          DirectShowUtil.FinalReleaseComObject(graphBuilder);
          graphBuilder = null;
        }

        if (VMR9Util.g_vmr9 != null)
        {
          VMR9Util.g_vmr9.SafeDispose();
          VMR9Util.g_vmr9 = null;
        }

        GUIGraphicsContext.form.Invalidate(true);
        _state = PlayState.Init;

        if (_mpegDemux != null)
        {
          Log.Info("cleanup mpegdemux");
          DirectShowUtil.FinalReleaseComObject(_mpegDemux);
          _mpegDemux = null;
        }
        if (_rtspSource != null)
        {
          Log.Info("cleanup _rtspSource");
          DirectShowUtil.FinalReleaseComObject(_rtspSource);
          _rtspSource = null;
        }
        if (_subtitleFilter != null)
        {
          DirectShowUtil.FinalReleaseComObject(_subtitleFilter);
          _subtitleFilter = null;
          if (this.dvbSubRenderer != null)
          {
            this.dvbSubRenderer.SetPlayer(null);
          }
          this.dvbSubRenderer = null;
        }


        if (vobSub != null)
        {
          Log.Info("cleanup vobSub");
          DirectShowUtil.FinalReleaseComObject(vobSub);
          vobSub = null;
        }
      }
      catch (Exception ex)
      {
        Log.Error("RTSPPlayer: Exception while cleanuping DShow graph - {0} {1}", ex.Message, ex.StackTrace);
      }

      //switch back to directx windowed mode
      Log.Info("RTSPPlayer: Disabling DX9 exclusive mode");
      GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null);
      GUIWindowManager.SendMessage(msg);
    }
开发者ID:MediaPortal,项目名称:MediaPortal-1,代码行数:99,代码来源:RTSPPlayer.cs


示例8: renderGraph


//.........这里部分代码省略.........
				this.InitVideoRenderer();
				this.AddDeInterlaceFilter();

				// When capture pin is used, preview works immediately,
				// however this conflicts with file saving.
				// An alternative is to use VMR9
                cat = PinCategory.Preview;
				med = MediaType.Video;
// #if NEWCODE
				if(this.InitSampleGrabber())
				{
					Debug.WriteLine("SampleGrabber added to graph.");

#if DSHOWNET
					hr = captureGraphBuilder.RenderStream(ref cat, ref med, videoDeviceFilter, this.baseGrabFlt, this.videoRendererFilter); 
#else
					hr = captureGraphBuilder.RenderStream(DsGuid.FromGuid(cat), DsGuid.FromGuid(med), videoDeviceFilter, this.baseGrabFlt, this.videoRendererFilter); 
#endif
					if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
				}
				else
// #endif NEWCODE
				{
#if DSHOWNET
					hr = captureGraphBuilder.RenderStream(ref cat, ref med, videoDeviceFilter, null, this.videoRendererFilter);
#else
					hr = captureGraphBuilder.RenderStream(DsGuid.FromGuid(cat), DsGuid.FromGuid(med), videoDeviceFilter, null, this.videoRendererFilter); 
#endif
					if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
				}

				// Special option to enable rendering audio via PCI bus
				if((this.AudioViaPci)&&(audioDeviceFilter != null))
				{
					cat = PinCategory.Preview;
					med = MediaType.Audio;
#if DSHOWNET
					hr = captureGraphBuilder.RenderStream( ref cat, ref med, audioDeviceFilter, null, null ); 
#else
                    hr = captureGraphBuilder.RenderStream(DsGuid.FromGuid(cat), DsGuid.FromGuid(med), audioDeviceFilter, null, null);
#endif
					if( hr < 0 )
					{
						Marshal.ThrowExceptionForHR( hr );
					}
				}
				else
					if( (this.AudioViaPci)&&
					(this.audioDeviceFilter == null)&&(this.videoDeviceFilter != null) )
				{
					cat = PinCategory.Preview;
					med = MediaType.Audio;
#if DSHOWNET
					hr = captureGraphBuilder.RenderStream( ref cat, ref med, videoDeviceFilter, null, null ); 
#else
                    hr = captureGraphBuilder.RenderStream(cat, med, videoDeviceFilter, null, null);
#endif
					if( hr < 0 )
					{
						Marshal.ThrowExceptionForHR( hr );
					}
				}

				// Get the IVideoWindow interface
				videoWindow = (IVideoWindow) graphBuilder;

				// Set the video window to be a child of the main window
				hr = videoWindow.put_Owner( previewWindow.Handle );
				if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

				// Set video window style
#if DSHOWNET
				hr = videoWindow.put_WindowStyle( WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
#else
			    hr = videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings);
#endif
				if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

				// Position video window in client rect of owner window
				previewWindow.Resize += new EventHandler( onPreviewWindowResize );
				onPreviewWindowResize( this, null );

				// Make the video window visible, now that it is properly positioned
#if DSHOWNET
				hr = videoWindow.put_Visible( DsHlp.OATRUE );
#else
				hr = videoWindow.put_Visible( OABool.True );
#endif
				if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );

				isPreviewRendered = true;
				didSomething = true;
// #if NEWCODE
				SetMediaSampleGrabber();
// #endif NEWCODE
			}

			if ( didSomething )
				graphState = GraphState.Rendered;
		}
开发者ID:rajeper,项目名称:ikarus-osd,代码行数:101,代码来源:Capture.cs


示例9: Initialize

        public override void Initialize(Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            const int wsChild = 0x40000000;

            var extension = System.IO.Path.GetExtension(videoFileName);
            if (extension == null)
            {
                return;
            }

            string ext = extension.ToLower();
            bool isAudio = ext == ".mp3" || ext == ".wav" || ext == ".wma" || ext == ".m4a";

            OnVideoLoaded = onVideoLoaded;
            OnVideoEnded = onVideoEnded;

            VideoFileName = videoFileName;
            owner = ownerControl;
            quartzFilgraphManager = new FilgraphManager();
            quartzFilgraphManager.RenderFile(VideoFileName);

            if (!isAudio)
            {
                quartzVideo = quartzFilgraphManager as IVideoWindow;
                if (quartzVideo != null)
                {
                    quartzVideo.Owner = (int)ownerControl.Handle;
                    quartzVideo.SetWindowPosition(0, 0, ownerControl.Width, ownerControl.Height);
                    quartzVideo.WindowStyle = wsChild;
                }
            }
            //Play();

            if (!isAudio)
            {
                var basicVideo = quartzFilgraphManager as IBasicVideo;
                if (basicVideo != null)
                {
                    basicVideo.GetVideoSize(out sourceWidth, out sourceHeight);
                }
            }

            owner.Resize += OwnerControlResize;
            mediaPosition = (IMediaPosition)quartzFilgraphManager;
            if (OnVideoLoaded != null)
            {
                videoLoader = new BackgroundWorker();
                videoLoader.RunWorkerCompleted += VideoLoaderRunWorkerCompleted;
                videoLoader.DoWork += VideoLoaderDoWork;
                videoLoader.RunWorkerAsync();
            }

            OwnerControlResize(this, null);
            videoEndTimer = new Timer { Interval = 500 };
            videoEndTimer.Tick += VideoEndTimerTick;
            videoEndTimer.Start();

            if (isAudio)
            {
                return;
            }

            if (quartzVideo != null)
            {
                quartzVideo.MessageDrain = (int)ownerControl.Handle;
            }
        }
开发者ID:AsenTahchiyski,项目名称:SoftUni-Projects,代码行数:67,代码来源:QuartsPlayer.cs


示例10: Run

        private void Run()
        {
            if (this.fmc == null)
                return;

            IGraphBuilder igb = (IGraphBuilder)this.fmc;

            try
            {
                // tell the graph builder about the filter graph
                this.icgb.SetFiltergraph(igb);

                igb.AddFilter(this.sf, "Video Capture");
                igb.AddFilter(this.sgf, "Sample Grabber");

                this.icgb.RenderStream(ref PIN_CATEGORY_CAPTURE, ref MEDIATYPE_Video, this.sf, this.sgf, null);

                // access different interfaces, ask runtime to notify this window
                this.ime = (IMediaEventEx)this.fmc;
                this.ime.SetNotifyWindow((int)this.Handle, WM_GRAPHNOTIFY, 0);

                // sets the video owner and style of this window
                this.ivw = (IVideoWindow)this.fmc;
                this.ivw.Owner = (int)this.Handle;
                this.ivw.WindowStyle = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

                ivw.SetWindowPosition(this.ClientRectangle.Left, this.ClientRectangle.Top, this.ClientRectangle.Width, this.ClientSize.Height - this.btnCapture.Height - vertical_space);

                // get the ball rolling
                this.fmc.Run();
            }
            catch (Exception ex)
            {
                Cleanup(false);
                MessageBox.Show("Couldn't run: " + ex.Message);
            }
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:37,代码来源:CaptureGraphForm.cs


示例11: ConfigureVideoWindow

        // Configure the video window
        private void ConfigureVideoWindow(IVideoWindow videoWindow, Control hWin)
        {
            int hr;

            // Set the output window
            hr = videoWindow.put_Owner(hWin.Handle);
            DsError.ThrowExceptionForHR(hr);

            // Set the window style
            hr = videoWindow.put_WindowStyle((WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings));
            DsError.ThrowExceptionForHR(hr);

            // Make the window visible
            hr = videoWindow.put_Visible(OABool.True);
            DsError.ThrowExceptionForHR(hr);

            // Position the playing location
            Rectangle rc = hWin.ClientRectangle;
            hr = videoWindow.SetWindowPosition(0, 0, rc.Right, rc.Bottom);
            DsError.ThrowExceptionForHR(hr);
        }
开发者ID:nikolasbe,项目名称:ugent-dma-videoshotdetection,代码行数:22,代码来源:DxPlay.cs


示例12: FindCaptureDevice

        /*
        // Uncomment this version of FindCaptureDevice to use the DsDevice helper class
        // (and comment the first version of course)
        public IBaseFilter FindCaptureDevice()
        {
          System.Collections.ArrayList devices;
          object source;

          // Get all video input devices
          devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

          // Take the first device
          DsDevice device = (DsDevice)devices[0];

          // Bind Moniker to a filter object
          Guid iid = typeof(IBaseFilter).GUID;
          device.Mon.BindToObject(null, null, ref iid, out source);

          // An exception is thrown if cast fail
          return (IBaseFilter) source;
        }
        */
        public void GetInterfaces()
        {
            int hr = 0;

              // An exception is thrown if cast fail
              this.graphBuilder = (IGraphBuilder) new FilterGraph();
              this.captureGraphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
              this.mediaControl = (IMediaControl) this.graphBuilder;
              this.videoWindow = (IVideoWindow) this.graphBuilder;
              this.mediaEventEx = (IMediaEventEx) this.graphBuilder;

              hr = this.mediaEventEx.SetNotifyWindow(this.Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
              DsError.ThrowExceptionForHR(hr);
        }
开发者ID:coolsula,项目名称:vidplaycorder,代码行数:36,代码来源:Form1.cs


示例13: GetDVDInterfaces


//.........这里部分代码省略.........
                catch (Exception ex)
                {
                    string strEx = ex.Message;
                }

                Guid riid;

                if (_dvdInfo == null)
                {
                    riid = typeof(IDvdInfo2).GUID;
                    hr = _dvdGraph.GetDvdInterface(riid, out comobj);
                    if (hr < 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    _dvdInfo = (IDvdInfo2)comobj;
                    comobj = null;
                }

                if (_dvdCtrl == null)
                {
                    riid = typeof(IDvdControl2).GUID;
                    hr = _dvdGraph.GetDvdInterface(riid, out comobj);
                    if (hr < 0)
                    {
                        Marshal.ThrowExceptionForHR(hr);
                    }
                    _dvdCtrl = (IDvdControl2)comobj;
                    comobj = null;
                }

                _mediaCtrl = (IMediaControl)_graphBuilder;
                _mediaEvt = (IMediaEventEx)_graphBuilder;
                _basicAudio = _graphBuilder as IBasicAudio;
                _mediaPos = (IMediaPosition)_graphBuilder;
                _mediaSeek = (IMediaSeeking)_graphBuilder;
                _mediaStep = (IVideoFrameStep)_graphBuilder;
                _basicVideo = _graphBuilder as IBasicVideo2;
                _videoWin = _graphBuilder as IVideoWindow;

                // disable Closed Captions!
                IBaseFilter baseFilter;
                _graphBuilder.FindFilterByName("Line 21 Decoder", out baseFilter);
                if (baseFilter == null)
                {
                    _graphBuilder.FindFilterByName("Line21 Decoder", out baseFilter);
                }
                if (baseFilter != null)
                {
                    _line21Decoder = (IAMLine21Decoder)baseFilter;
                    if (_line21Decoder != null)
                    {
                        AMLine21CCState state = AMLine21CCState.Off;
                        hr = _line21Decoder.SetServiceState(state);
                        if (hr == 0)
                        {
                            logger.Info("DVDPlayer:Closed Captions disabled");
                        }
                        else
                        {
                            logger.Info("DVDPlayer:failed 2 disable Closed Captions");
                        }
                    }
                }
                /*
                        // get video window
                        if (_videoWin==null)
                        {
                          riid = typeof( IVideoWindow ).GUID;
                          hr = _dvdGraph.GetDvdInterface( ref riid, out comobj );
                          if( hr < 0 )
                            Marshal.ThrowExceptionForHR( hr );
                          _videoWin = (IVideoWindow) comobj; comobj = null;
                        }
                  */
                // GetFrameStepInterface();

                DirectShowUtil.SetARMode(_graphBuilder, arMode);
                DirectShowUtil.EnableDeInterlace(_graphBuilder);
                //m_ovMgr = new OVTOOLLib.OvMgrClass();
                //m_ovMgr.SetGraph(_graphBuilder);

                return true;
            }
            catch (Exception)
            {

                //MessageBox.Show( this, "Could not get interfaces\r\n" + ee.Message, "DVDPlayer.NET", MessageBoxButtons.OK, MessageBoxIcon.Stop );
                CloseDVDInterfaces();
                return false;
            }
            finally
            {
                if (comobj != null)
                {
                    DirectShowUtil.ReleaseComObject(comobj);
                }
                comobj = null;
            }
        }
开发者ID:andrewjswan,项目名称:mvcentral,代码行数:101,代码来源:Grabber.cs


示例14: PlayMovieInWindow


//.........这里部分代码省略.........
            if (EVRControl == null)
            {
                //Ищем рендерер и ВКЛЮЧАЕМ соблюдение аспекта (рендерер сам подгонит картинку под размер окна, с учетом аспекта)
                IsRendererARFixed = false;
                IBaseFilter filter = null;
                graphBuilder.FindFilterByName("Video Renderer", out filter);
                if (filter != null)
                {
                    IVMRAspectRatioControl vmr = filter as IVMRAspectRatioControl;
                    if (vmr != null)
                    {
                        DsError.ThrowExceptionForHR(vmr.SetAspectRatioMode(VMRAspectRatioMode.LetterBox));
                        IsRendererARFixed = true;
                    }
                }
                else
                {
                    graphBuilder.FindFilterByName("Video Mixing Renderer 9", out filter);
                    if (filter != null)
                    {
                        IVMRAspectRatioControl9 vmr9 = filter as IVMRAspectRatioControl9;
                        if (vmr9 != null)
                        {
                            DsError.ThrowExceptionForHR(vmr9.SetAspectRatioMode(VMRAspectRatioMode.LetterBox));
                            IsRendererARFixed = true;
                        }
                    }
                }
            }
            else
                IsRendererARFixed = true;

            this.mediaControl = (IMediaControl)this.graphBuilder;
            this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
            this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
            this.mediaPosition = (IMediaPosition)this.graphBuilder;
            this.videoWindow = (EVRControl == null) ? this.graphBuilder as IVideoWindow : null;
            this.basicVideo = (EVRControl == null) ? this.graphBuilder as IBasicVideo : null;
            this.basicAudio = this.graphBuilder as IBasicAudio;
            this.basicAudio.put_Volume(VolumeSet);
            this.CheckIsAudioOnly();
            if (!this.isAudioOnly)
            {
                if (videoWindow != null)
                {
                    hr = this.videoWindow.put_Owner(this.source.Handle);
                    DsError.ThrowExceptionForHR(hr);

                    hr = this.videoWindow.put_MessageDrain(this.source.Handle);
                    DsError.ThrowExceptionForHR(hr);

                    hr = this.videoWindow.put_WindowStyle(DirectShowLib.WindowStyle.Child | DirectShowLib.WindowStyle.ClipSiblings | DirectShowLib.WindowStyle.ClipChildren);
                    DsError.ThrowExceptionForHR(hr);
                }

                this.MoveVideoWindow();
            }
            else
            {
                if (VHost != null)
                {
                    VHost.Dispose();
                    VHost = null;
                    VHandle = IntPtr.Zero;
                    VHostElement.Child = null;
                    VHostElement.Visibility = Visibility.Collapsed;
                }
            }

            hr = this.mediaEventEx.SetNotifyWindow(this.source.Handle, WMGraphNotify, IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);

            //Восстанавливаем старую позицию
            if (mediaload == MediaLoad.Update && oldpos != TimeSpan.Zero)
            {
                if (NaturalDuration >= oldpos)
                {
                    hr = mediaPosition.put_CurrentPosition(oldpos.TotalSeconds);
                    DsError.ThrowExceptionForHR(hr);
                }
            }

            //Восстанавливаем старый PlayState
            if (mediaload == MediaLoad.Update && (oldplaystate == PlayState.Paused || oldplaystate == PlayState.Stopped))
            {
                hr = this.mediaControl.Pause();
                DsError.ThrowExceptionForHR(hr);
                this.currentState = PlayState.Paused;
                this.SetPlayIcon();
            }
            else
            {
                hr = this.mediaControl.Run();
                DsError.ThrowExceptionForHR(hr);
                this.currentState = PlayState.Running;
                this.SetPauseIcon();
            }

            AddFiltersToMenu();
        }
开发者ID:MaksHDR,项目名称:xvid4psp,代码行数:101,代码来源:MainWindow.xaml.cs


示例15: InitVideoWindow

        private void InitVideoWindow()
        {
            if (Render == null)
                return;

            videoWindow = (IVideoWindow)graphBuilder;

            //Set the owener of the videoWindow to an IntPtr of some sort (the Handle of any control - could be a form / button etc.)
            var hr = videoWindow.put_Owner(Render.Handle);
            DsError.ThrowExceptionForHR(hr);
            //Set the style of the video window
            hr = videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings);
            DsError.ThrowExceptionForHR(hr);

            // Position video window in client rect of main application window
            //hr = videoWindow.SetWindowPosition(0, 0, Render.Width, Render.Height);
            Resize();
            DsError.ThrowExceptionForHR(hr);
            videoWindow.put_Visible(OABool.True);
            Render.SizeChanged -= new EventHandler(onResize);
            Render.SizeChanged += new EventHandler(onResize);
        }
开发者ID:ssnake,项目名称:utuner,代码行数:22,代码来源:tuner.cs


示例16: CloseInterfaces

    /// <summary> do cleanup and release DirectShow. </summary>
    protected void CloseInterfaces()
    {
      if (_graphBuilder == null)
      {
        return;
      }
      int hr;
      Log.Debug("BDPlayer: Cleanup DShow graph {0}", GUIGraphicsContext.InVmr9Render);
      try
      {
        BDOSDRenderer.Release();
        
        if (_mediaCtrl != null)
        {
          int counter = 0;
          FilterState state;
          hr = _mediaCtrl.Stop();
          hr = _mediaCtrl.GetState(10, out state);
          while (state != FilterState.Stopped || GUIGraphicsContext.InVmr9Render)
          {
            Thread.Sleep(100);
            hr = _mediaCtrl.GetState(10, out state);
            counter++;
            if (counter >= 30)
            {
              if (state != FilterState.Stopped)
                Log.Error("BDPlayer: graph still running");
              if (GUIGraphicsContext.InVmr9Render)
                Log.Error("BDPlayer: in renderer");
              break;
            }
          }
          _mediaCtrl = null;
        }

        if (_vmr9 != null)
        {
          _vmr9.Enable(false);
        }

        if (_mediaEvt != null)
        {
          hr = _mediaEvt.SetNotifyWindow(IntPtr.Zero, WM_GRAPHNOTIFY, IntPtr.Zero);
          _mediaEvt = null;
        }

        _videoWin = _graphBuilder as IVideoWindow;
        if (_videoWin != null)
        {
          hr = _videoWin.put_Visible(OABool.False);
          hr = _videoWin.put_Owner(IntPtr.Zero);
          _videoWin = null;
        }

        _mediaSeeking = null;
        _basicAudio = null;
        _basicVideo = null;
        _ireader = null;

        #region Cleanup Sebastiii

        if (VideoCodec != null)
        {
          DirectShowUtil.ReleaseComObject(VideoCodec, 5000);
          VideoCodec = null;
          Log.Info("BDPlayer: Cleanup VideoCodec");
        }

        if (AudioCodec != null)
        {
          DirectShowUtil.ReleaseComObject(AudioCodec, 5000);
          AudioCodec = null;
          Log.Info("BDPlayer: Cleanup AudioCodec");
        }

        if (_audioRendererFilter != null)
        {
          while (DirectShowUtil.ReleaseComObject(_audioRendererFilter) > 0) ;
          _audioRendererFilter = null;
          Log.Info("BDPlayer: Cleanup AudioRenderer");
        }

        //Test to ReleaseComObject from PostProcessFilter list objects.
        if (PostProcessFilterVideo.Count > 0)
        {
          foreach (var ppFilter in PostProcessFilterVideo)
          {
            if (ppFilter.Value != null) DirectShowUtil.ReleaseComObject(ppFilter.Value, 5000);
          }
          PostProcessFilterVideo.Clear();
          Log.Info("BDPlayer: Cleanup PostProcessVideo");
        }

        //Test to ReleaseComObject from PostProcessFilter list objects.
        if (PostProcessFilterAudio.Count > 0)
        {
          foreach (var ppFilter in PostProcessFilterAudio)
          {
            if (ppFilter.Value != null) DirectShowUtil.ReleaseComObject(ppFilter.Value, 5000);
//.........这里部分代码省略.........
开发者ID:Erls-Corporation,项目名称:MediaPortal-1,代码行数:101,代码来源:BDPlayer.cs


示例17: BuildGraph


//.........这里部分代码省略.........
                DsError.ThrowExceptionForHR(hr);

                hr = m_graph.AddFilter(dummyRenderer, "Dummy Windowed");
                DsError.ThrowExceptionForHR(hr);

                if (dvdAudioPin != null)
                {
                    /* This should render out to the default audio device. We
                     * could modify this code here to go out any audio
                     * device, such as SPDIF or another sound card */
                    hr = m_graph.Render(dvdAudioPin);
                    DsError.ThrowExceptionForHR(hr);
                }

                /* Get the first input pin on our dummy renderer */
                m_dummyRendererPin = DsFindPin.ByConnectionStatus(dummyRenderer, /* Filter to search */
                                                                  PinConnectedStatus.Unconnected,
                                                                  0);

                /* Get an available pin on our real renderer */
                IPin rendererPin = DsFindPin.ByConnectionStatus(m_renderer, /* Filter to search */
                                                                PinConnectedStatus.Unconnected,
                                                                0); /* Pin index */

                /* Connect the pin to the renderer */
                hr = m_graph.Connect(dvdVideoPin, rendererPin);
                DsError.ThrowExceptionForHR(hr);

                /* Get the next available pin on our real renderer */
                rendererPin = DsFindPin.ByConnectionStatus(m_renderer, /* Filter to search */
                                                           PinConnectedStatus.Unconnected,
                                                           0); /* Pin index */

                /* Render the sub picture, which will connect
                 * the DVD navigator to the codec, not the renderer */
                hr = m_graph.Render(dvdSubPicturePin);
                DsError.ThrowExceptionForHR(hr);

                /* These are the subtypes most likely to be our dvd subpicture */
                var preferedSubpictureTypes = new[]{MediaSubType.ARGB4444,
                                                    MediaSubType.AI44,
                                                    MediaSubType.AYUV,
                                                    MediaSubType.ARGB32};
                IPin dvdSubPicturePinOut = null;

                /* Find what should be the subpicture pin out */
                foreach (var guidType in preferedSubpictureTypes)
                {
                    dvdSubPicturePinOut = FindPinInGraphByMediaType(guidType, /* GUID of the media type being searched for */
                                                                    PinDirection.Output,
                                                                    m_graph); /* Our current graph */
                    if (dvdSubPicturePinOut != null)
                        break;
                }

                if (dvdSubPicturePinOut == null)
                    throw new Exception("Could not find the sub picture pin out");

                /* Here we connec thte Dvd sub picture pin to the video renderer.
                 * This enables the overlays on Dvd menus and some closed
                 * captions to be rendered. */
                hr = m_graph.Connect(dvdSubPicturePinOut, rendererPin);
                DsError.ThrowExceptionForHR(hr);

                /* Search for the Line21 out in the graph */
                IPin line21Out = FindPinInGraphByMediaType(MediaType.AuxLine21Data,
                                                           PinDirection.Output,
                                                           m_graph);
                if (line21Out == null)
                    throw new Exception("Could not find the Line21 pin out");

                /* We connect our line21Out out in to the dummy renderer
                 * this is what ultimatly makes interactive DVDs work with
                 * VMR9 in renderless (for WPF) */
                hr = m_graph.Connect(line21Out, m_dummyRendererPin);
                DsError.ThrowExceptionForHR(hr);

                /* This is the dummy renderers Win32 window. */
                m_dummyRenderWindow = dummyRenderer as IVideoWindow;

                if (m_dummyRenderWindow == null)
                    throw new Exception("Could not QueryInterface for IVideoWindow");

                ConfigureDummyWindow();

                /* Setup our base classes with this filter graph */
                SetupFilterGraph(m_graph);

                /* Sets the NaturalVideoWidth/Height */
                SetNativePixelSi 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IView类代码示例发布时间:2022-05-24
下一篇:
C# IVideoSource类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap