当前位置: 首页>>代码示例>>C#>>正文


C# IGraphBuilder.RenderFile方法代码示例

本文整理汇总了C#中IGraphBuilder.RenderFile方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphBuilder.RenderFile方法的具体用法?C# IGraphBuilder.RenderFile怎么用?C# IGraphBuilder.RenderFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphBuilder的用法示例。


在下文中一共展示了IGraphBuilder.RenderFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: loadVideo

        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;
        }
开发者ID:Epitanime,项目名称:MadShoKen,代码行数:86,代码来源:mainForm.cs

示例3: GetInterfaces

    /// <summary> create the used COM components and get the interfaces. </summary>
    private bool GetInterfaces()
    {
      int iStage = 1;
      string audioDevice;
      using (Settings xmlreader = new MPSettings())
      {
        audioDevice = xmlreader.GetValueAsString("audioplayer", "sounddevice", "Default DirectSound Device");
      }
      //Type comtype = null;
      //object comobj = null;
      try
      {
        graphBuilder = (IGraphBuilder)new FilterGraph();
        iStage = 5;
        DirectShowUtil.AddAudioRendererToGraph(graphBuilder, audioDevice, false);
        int hr = graphBuilder.RenderFile(m_strCurrentFile, null);
        if (hr != 0)
        {
          Error.SetError("Unable to play file", "Missing codecs to play this file");
          return false;
        }
        iStage = 6;
        mediaCtrl = (IMediaControl)graphBuilder;

        iStage = 7;
        mediaEvt = (IMediaEventEx)graphBuilder;
        iStage = 8;
        mediaSeek = (IMediaSeeking)graphBuilder;
        iStage = 9;
        mediaPos = (IMediaPosition)graphBuilder;
        iStage = 10;
        basicAudio = graphBuilder as IBasicAudio;
        iStage = 11;
        return true;
      }
      catch (Exception ex)
      {
        Log.Info("Can not start {0} stage:{1} err:{2} stack:{3}",
                 m_strCurrentFile, iStage,
                 ex.Message,
                 ex.StackTrace);
        return false;
      }
    }
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:45,代码来源:AudioPlayerVMR.cs

示例4: CreateGraph

 private void CreateGraph()
 {
     graphBuilder = (IGraphBuilder)new FilterGraph();
     graphBuilder.RenderFile(tempFileName, null);
     mediaControl = (IMediaControl)graphBuilder;
     mediaSeeking = (IMediaSeeking)graphBuilder;
     mediaEvent = (IMediaEventEx)graphBuilder;
     //var filter = new MpqFileSourceFilter(File);
     //DsError.ThrowExceptionForHR(graphBuilder.AddFilter(filter, filter.Name));
     //DsError.ThrowExceptionForHR(graphBuilder.Render(filter.OutputPin));
     mediaSeeking.GetCapabilities(out seekingCapabilities);
     mediaSeeking.SetTimeFormat(TimeFormat.MediaTime);
     mediaEvent.SetNotifyWindow(Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
 }
开发者ID:sgraf812,项目名称:crystalmpq,代码行数:14,代码来源:MediaPlayer.cs

示例5: BridgeCallback

        private void BridgeCallback(MediaBridge.MediaBridgeGraphInfo GraphInfo)
        {
            try
            {
                int hr = 0;

                //Convert pointer of filter graph to an object we can use
                graph = (IFilterGraph)Marshal.GetObjectForIUnknown(GraphInfo.FilterGraph);
                graphBuilder = (IGraphBuilder)graph;

                hr = graphBuilder.RenderFile(filepath, null);
                DsError.ThrowExceptionForHR(hr);
            }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate()
                {
                    ErrorException("BridgeCallback: " + ex.Message, ex.StackTrace);
                    PreviewError(Languages.Translate("Error") + "...", Brushes.Red);
                });
            }
        }
开发者ID:MaksHDR,项目名称:xvid4psp,代码行数:22,代码来源:MainWindow.xaml.cs

示例6: Play

        void Play(String fileName)
        {
            try
            {
                graphBuilder = (IGraphBuilder)new FilterGraph();
                mediaCtrl = (IMediaControl)graphBuilder;
                mediaEvt = (IMediaEventEx)graphBuilder;
                mediaPos = (IMediaPosition)graphBuilder;
                videoWin = (IVideoWindow)graphBuilder;

                pane.getInfo(InfoQueue, fileName);
                graphBuilder.RenderFile( fileName, null );

                videoWin.put_Owner(Video_panel.Handle);
                //videoWin.put_Owner(this.Handle);
                videoWin.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);

                setWindow();
                mediaCtrl.Run();

                double total_time;
                mediaPos.get_Duration(out total_time);

                Video_timer.Enabled = true;
                iStatus = InfoStatus.Play;
                message_label.Width = 0;
                message_label.Height = 0;
            }
            catch (Exception)
            {
                MessageBox.Show("Couldn't start");
            }
        }
开发者ID:jw8957,项目名称:InterPlayer,代码行数:33,代码来源:MainForm.cs

示例7: checkRender

 /// <summary>
 /// Check whether DirectShow can render a video file
 /// </summary>
 /// <param name="fileName"></param>
 /// <returns>true if graphedit can render the input</returns>
 public bool checkRender(string fileName)
 {
     Type comtype = null;
     object comobj = null;
     try
     {
         comtype = Type.GetTypeFromCLSID(Clsid.FilterGraph);
         if (comtype == null)
             throw new NotSupportedException("DirectX (8.1 or higher) not installed?");
         comobj = Activator.CreateInstance(comtype);
         graphBuilder = (IGraphBuilder)comobj; comobj = null;
         int hr = graphBuilder.RenderFile(fileName, null);
         if (hr >= 0)
             return true;
         else
             return false;
     }
     catch (Exception)
     {
         return false;
         //throw (e); // May add more handling here later
     }
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:28,代码来源:DirectShow.cs

示例8: FileLoad

        //Мотод для загрузки видео файла.
        public void FileLoad(string sfile, Panel vPanel)
        {
            CleanUp();

            graphBuilder  = (IGraphBuilder) new FilterGraph();
            mediaControl  = graphBuilder as IMediaControl;
            mediaPosition = graphBuilder as IMediaPosition;
            videoWindow   = graphBuilder as IVideoWindow;
            basicAudio    = graphBuilder as IBasicAudio;

            ddColor.lBrightness = 0;
            ddColor.lContrast = 0;
            ddColor.lGamma = 0;
            ddColor.lSaturation = 0;

            graphBuilder.RenderFile(sfile, null);
            videoWindow.put_Owner(vPanel.Handle);
            videoWindow.put_WindowStyle(WindowStyle.Child
                                      | WindowStyle.ClipSiblings
                                      | WindowStyle.ClipChildren);
            videoWindow.SetWindowPosition(vPanel.ClientRectangle.Left,
                                          vPanel.ClientRectangle.Top,
                                          vPanel.ClientRectangle.Width,
                                          vPanel.ClientRectangle.Height);

            mediaControl.Run();
            CurrentStatus = mStatus.Play;
            mediaPosition.get_Duration(out mediaTimeSeconds);
            allSeconds = (int)mediaTimeSeconds;
        }
开发者ID:NVZver,项目名称:DirectShow,代码行数:31,代码来源:Media.cs

示例9: Open_Call

        protected override void Open_Call(string filename)
        {
            int hr = 0;

            graphBuilder = (IGraphBuilder) new FilterGraph();

            // Have the graph builder construct its the appropriate graph automatically
            hr = graphBuilder.RenderFile(filename, null);
            DsError.ThrowExceptionForHR(hr);
            /*
            try
            {
                hr = graphBuilder.RenderFile(filename, null);
                DsError.ThrowExceptionForHR(hr);
            }
            catch(Exception ex)
            {
                SystemMessage.Show(
                    Loc.T("Player.Message.CantOpenVideoFile") + Environment.NewLine+ Environment.NewLine +
                    "Exeption details :" + Environment.NewLine +
                     ex.Message + Environment.NewLine +
                     ex.Source
                    );
                return;
            }
            */
            // QueryInterface for DirectShow interfaces
            mediaControl = (IMediaControl) graphBuilder;
            mediaEventEx = (IMediaEventEx) graphBuilder;
            //mediaSeeking = (IMediaSeeking) graphBuilder;
            mediaPosition = (IMediaPosition) graphBuilder;

            // Query for video interfaces, which may not be relevant for audio files
            videoWindow = graphBuilder as IVideoWindow;
            basicVideo = graphBuilder as IBasicVideo;

            // Query for audio interfaces, which may not be relevant for video-only files
            basicAudio = graphBuilder as IBasicAudio;


            // Have the graph signal event via window callbacks for performance
            hr = mediaEventEx.SetNotifyWindow(Handle, WMGraphNotify, IntPtr.Zero);
            DsError.ThrowExceptionForHR(hr);

            // Setup the video window
            hr = this.videoWindow.put_Owner(Handle);
            DsError.ThrowExceptionForHR(hr);

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

            try
            {
                Host_SizeChanged(null, null);
            }
            catch { }
            

            #if DEBUG
                rot = new DsROTEntry(this.graphBuilder);
            #endif

            //this.Focus();

            // Run the graph to play the media file
            hr = this.mediaControl.Run();
            DsError.ThrowExceptionForHR(hr);

        }
开发者ID:vlkam,项目名称:OpenLearningPlayer,代码行数:69,代码来源:DirectShowPlayer.cs

示例10: BridgeCallback

        private void BridgeCallback(MediaBridge.MediaBridgeGraphInfo GraphInfo)
        {
            try
            {
                int hr = 0;

                //Convert pointer of filter graph to an object we can use
                graph = (IFilterGraph)Marshal.GetObjectForIUnknown(GraphInfo.FilterGraph);
                graphBuilder = (IGraphBuilder)graph;

                hr = graphBuilder.RenderFile(filepath, null);
                DsError.ThrowExceptionForHR(hr);
            }
            catch (Exception ex)
            {
                ErrorException("BridgeCallback: " + ex.Message, ex.StackTrace);
            }
        }
开发者ID:BrunoReX,项目名称:xvid4psp,代码行数:18,代码来源:DVDImport.xaml.cs

示例11: openVid

        public void openVid(string fileName)
        {
            if (!File.Exists(fileName))
            {
                errorMsg("El archivo '" + fileName + "' no existe.");
                videoPanel.Visible = false;
                isVideoLoaded = false;
                drawPositions();
                return;
            }

            if (VideoBoxType == PreviewType.AviSynth)
            {
                avsClip = null;
                //butPause.Enabled = true;
                //butPlayR.Enabled = true;
                //butPlay.Enabled = true;
                //butStop.Enabled = true;
                videoPictureBox.Visible = false;
                //closeVidDShow(); // añadido
            }

            if (mediaControl != null)
            {
                mediaControl.Stop();
                videoWindow.put_Visible(DirectShowLib.OABool.False);
                videoWindow.put_Owner(IntPtr.Zero);
            }

            // Dshow :~~

            graphBuilder = (IGraphBuilder)new FilterGraph();
            graphBuilder.RenderFile(fileName, null);
            mediaControl = (IMediaControl)graphBuilder;
            // mediaEventEx = (IMediaEventEx)this.graphBuilder;
            mediaSeeking = (IMediaSeeking)graphBuilder;
            mediaPosition = (IMediaPosition)graphBuilder;
            basicVideo = graphBuilder as IBasicVideo;
            videoWindow = graphBuilder as IVideoWindow;

            VideoBoxType = PreviewType.DirectShow;

            // sacando información

            int x, y; double atpf;
            basicVideo.GetVideoSize(out x, out y);
            if (x == 0 || y == 0)
            {
                errorMsg("No se puede abrir un vídeo sin dimensiones.");
                videoPanel.Visible = false;
                isVideoLoaded = false;
                drawPositions();
                return;
            }

            if (videoInfo == null) videoInfo = new VideoInfo(fileName);

            videoInfo.Resolution = new Size(x, y);

            basicVideo.get_AvgTimePerFrame(out atpf);
            videoInfo.FrameRate = Math.Round(1 / atpf, 3);

            //labelResFPS.Text = x.ToString() + "x" + y.ToString() + " @ " + videoInfo.FrameRate.ToString() + " fps";
            textResX.Text = x.ToString();
            textResY.Text = y.ToString();
            textFPS.Text = videoInfo.FrameRate.ToString();

            if (File.Exists(Application.StartupPath+"\\MediaInfo.dll") && File.Exists(Application.StartupPath+"\\MediaInfoWrapper.dll"))
            {
                treeView1.Enabled = true;
                try
                {
                    RetrieveMediaFileInfo(fileName);
                }
                catch { treeView1.Enabled = false; }
            }
            else treeView1.Enabled = false;

            if (x != 0)
            {
                vidScaleFactor.Enabled = true;

                try
                {
                    vidScaleFactor.Text = getFromConfigFile("mainW_Zoom");
                }
                catch
                {
                    vidScaleFactor.Text = "50%";
                };

                double p = double.Parse(vidScaleFactor.Text.Substring(0, vidScaleFactor.Text.IndexOf('%')));
                p = p / 100;

                int new_x = (int)(x * p);
                int new_y = (int)(y * p);

                videoWindow.put_Height(new_x);
                videoWindow.put_Width(new_y);
                videoWindow.put_Owner(videoPanel.Handle);
//.........这里部分代码省略.........
开发者ID:nuukcillo,项目名称:PerrySub,代码行数:101,代码来源:DirectShowVideo.cs

示例12: translateW_Load

        private void translateW_Load(object sender, EventArgs e)
        {
            //this.MaximumSize = this.Size;
            //this.MinimumSize = this.Size;
            toolStripStatusLabel2.Text = "Cargando el Asistente de Traducción...";
            // cargamos script
            autoComplete = new ArrayList();
            al = mW.al;
            gridCont.RowCount = al.Count;

            bool hasAutoComplete = (mW.script.GetHeader().GetHeaderValue("AutoComplete") != string.Empty);

            for (int i = 0; i < al.Count; i++)
            {
                lineaASS lass = (lineaASS)al[i];
                gridCont[0, i].Value = lass.personaje;
                if (!autoComplete.Contains(lass.personaje) && !hasAutoComplete)
                    if (lass.personaje.Trim()!="")
                        autoComplete.Add(lass.personaje);
                gridCont[1, i].Value = lass.texto;
            }
            if (hasAutoComplete) InsertAutoCompleteFromScript();

            labelLineaActual.Text = "1 de " + (al.Count) + " (0%)";
            textPersonaje.Text = gridCont[0, 0].Value.ToString();
            textOrig.Text = gridCont[1, 0].Value.ToString();

            // cargamos video

            graphBuilder = (IGraphBuilder)new FilterGraph();
            graphBuilder.RenderFile(videoInfo.FileName, null);
            mediaControl = (IMediaControl)graphBuilder;
            // mediaEventEx = (IMediaEventEx)this.graphBuilder;
            mediaSeeking = (IMediaSeeking)graphBuilder;
            mediaPosition = (IMediaPosition)graphBuilder;
            basicVideo = graphBuilder as IBasicVideo;
            basicAudio = graphBuilder as IBasicAudio;
            videoWindow = graphBuilder as IVideoWindow;

            try
            {
                int x, y; double atpf;
                basicVideo.GetVideoSize(out x, out y);
                basicVideo.get_AvgTimePerFrame(out atpf);
                videoInfo.FrameRate = Math.Round(1 / atpf, 3);

                int new_x = videoPanel.Width;
                int new_y = (new_x * y) / x;
                videoWindow.put_Height(new_x);
                videoWindow.put_Width(new_y);
                videoWindow.put_Owner(videoPanel.Handle);
                videoPanel.Size = new System.Drawing.Size(new_x, new_y);
                videoWindow.SetWindowPosition(0, 0, videoPanel.Width, videoPanel.Height);
                videoWindow.put_WindowStyle(WindowStyle.Child);
                videoWindow.put_Visible(DirectShowLib.OABool.True);
                mediaSeeking.SetTimeFormat(DirectShowLib.TimeFormat.Frame);

                mediaControl.Run();
            }
            catch { mW.errorMsg("Imposible cargar el vídeo. Debe haber algún problema con el mismo, y el asistente será muy inestable"); }
            // activamos timers & handlers

            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Enabled = true;
            timer2.Tick += new EventHandler(timer2_Tick);
            AutoSaveTimer.Tick += new EventHandler(timer3_Tick);
            AutoSaveTimer.Enabled = true;

            gridCont.CellClick += new DataGridViewCellEventHandler(gridCont_CellClick);
            textPersonaje.TextChanged += new EventHandler(textPersonaje_TextChanged);
            textTradu.TextChanged += new EventHandler(textTradu_TextChanged);
            textTradu.KeyUp += new KeyEventHandler(textBox1_KeyUp);
            textTradu.KeyDown += new KeyEventHandler(textTradu_KeyDown);
            textTradu.KeyPress += new KeyPressEventHandler(textTradu_KeyPress);
            textPersonaje.KeyDown += new KeyEventHandler(textPersonaje_KeyDown);
            textPersonaje.KeyPress += new KeyPressEventHandler(textPersonaje_KeyPress);
            button8.GotFocus += new EventHandler(button8_GotFocus);
            button9.GotFocus += new EventHandler(button9_GotFocus);
            gridCont.DoubleClick += new EventHandler(gridCont_DoubleClick);
            gridCont.SelectionChanged += new EventHandler(gridCont_SelectionChanged);
            gridCont.KeyUp += new KeyEventHandler(gridCont_KeyUp);
            listBox1.KeyUp += new KeyEventHandler(listBox1_KeyUp);
            textToAdd.KeyPress += new KeyPressEventHandler(textToAdd_KeyPress);
            progressBar1.MouseDown += new MouseEventHandler(progressBar1_MouseDown);
            tiempoInicio_.TimeValidated += new TimeTextBox.OnTimeTextBoxValidated(tiempo_TimeValidated);
            tiempoFin_.TimeValidated += new TimeTextBox.OnTimeTextBoxValidated(tiempo_TimeValidated);
            this.Move += new EventHandler(translateW_Move);

            //textTradu.ContextMenu = new ASSTextBoxRegExDefaultContextMenu(textTradu);

            mediaControl.Pause();

            // cargar de config

            try
            {
                checkAutoComplete.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_autoC"));
                checkTagSSA.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_tagSSA"));
                checkComment.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_Comment"));
                checkVideo.Checked = Convert.ToBoolean(mW.getFromConfigFile("translateW_aud"));
//.........这里部分代码省略.........
开发者ID:nuukcillo,项目名称:PerrySub,代码行数:101,代码来源:translateW.cs

示例13: Open

        public bool Open(PandoraSong file) {
            try {
                Close();

                graphBuilder = (IGraphBuilder)new FilterGraph();

                // create interface objects for various actions
                mediaControl = (IMediaControl)graphBuilder;
                mediaEventEx = (IMediaEventEx)graphBuilder;
                mediaSeeking = (IMediaSeeking)graphBuilder;
                mediaPosition = (IMediaPosition)graphBuilder;
                basicAudio = (IBasicAudio)graphBuilder;

                int hr = 0;

                StartEventLoop();

                //hr = graphBuilder.AddFilter(

                // Have the graph builder construct its the appropriate graph automatically
                hr = graphBuilder.RenderFile(file.AudioURL, null);
                DsError.ThrowExceptionForHR(hr);

                // maintain previous volume level so it persists from track to track
                if (PreviousVolume != null)
                    Volume = (double)PreviousVolume;

                loadedSong = file;
                return true;
            }
            catch (Exception) {
                return false;
            }

        }
开发者ID:Bold-Taco,项目名称:SILO,代码行数:35,代码来源:DirectShowPlayer.cs

示例14: StartGraph

        private void StartGraph()
        {
            int hr = 0;

              CloseGraph();

              string path = GetMoviePath();
              if (path == string.Empty)
            return;

              try
              {
            graph = (IGraphBuilder) new FilterGraph();
            filter = (IBaseFilter) new VideoMixingRenderer9();

            IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9) filter;

            hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless);
            DsError.ThrowExceptionForHR(hr);

            hr = filterConfig.SetNumberOfStreams(2);
            DsError.ThrowExceptionForHR(hr);

            SetAllocatorPresenter();

            hr = graph.AddFilter(filter, "Video Mixing Renderer 9");
            DsError.ThrowExceptionForHR(hr);

            hr = graph.RenderFile(path, null);
            DsError.ThrowExceptionForHR(hr);

            mediaControl = (IMediaControl) graph;

            hr = mediaControl.Run();
            DsError.ThrowExceptionForHR(hr);
              }
              catch
              {
              }
        }
开发者ID:OmerMor,项目名称:DirectShowLib-FORK,代码行数:40,代码来源:MainForm.cs

示例15: SetAudioTrack_Call

        protected override void SetAudioTrack_Call(AudioTrack value)
        {
            int hr = 0;
            if (!value.isExternal)
            {
                isExternalAudio = false;

                IAMStreamSelect stream;
                IBaseFilter filter;
  
                filter = GetFilter(graphBuilder,".mkv");
                stream = (IAMStreamSelect)filter;

                int current = value.Number;
                hr = stream.Enable(current, AMStreamSelectEnableFlags.Enable);
                DsError.ThrowExceptionForHR(hr);

                //Debug.WriteLine("Using subtitles : " +current);
            } 
            else
            {
                isExternalAudio = true;

                if (graphBuilderExtAudio != null) Marshal.ReleaseComObject(graphBuilderExtAudio);
                graphBuilderExtAudio = (IGraphBuilder) new FilterGraph();

                mediaPositionExtAudio   = graphBuilderExtAudio as IMediaPosition;
                mediaControlExtAudio    = graphBuilderExtAudio as IMediaControl;
                basicAudioExtAudio      = graphBuilderExtAudio as IBasicAudio;

                string pathtofile = Path.Combine(FileService.GetPathToLearningItem(value.LearningItem),value.ExternalFile);
                // Have the graph builder construct its the appropriate graph automatically
                try
                {
                    hr = graphBuilderExtAudio.RenderFile(pathtofile, null);
                    DsError.ThrowExceptionForHR(hr);
                }
                catch(Exception ex)
                {
                    SystemMessage.Show(
                        Loc.T("Player.Message.CantOpenExternalAudioFile") +  Environment.NewLine
                        + pathtofile
                        + Environment.NewLine + Environment.NewLine +
                        "Exeption details :" + Environment.NewLine +
                         ex.Message + Environment.NewLine +
                         ex.Source
                        );
                    return;
                }

                #if DEBUG
                    rot = new DsROTEntry(graphBuilderExtAudio);
                #endif

                // Run the graph to play the media file
                hr = mediaControlExtAudio.Run();
                DsError.ThrowExceptionForHR(hr);

                SyncronizeVideoAndAudio();

            }
        }
开发者ID:vlkam,项目名称:OpenLearningPlayer,代码行数:62,代码来源:DirectShowPlayer.cs


注:本文中的IGraphBuilder.RenderFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。