コード例 #1
0
 protected virtual void OnPartialSuccess(UserDecisionEventArgs args)
 {
     args.Raise(this, ref PartialSuccess);
 }
コード例 #2
0
        /// <summary>
        /// Render new media.
        /// </summary>
        /// <param name="source">Filename.</param>
        /// <param name="mediaSourceType">One of the MediaSourceType.</param>
        /// <returns></returns>
        public bool BuildGraph(string source, MediaSourceType mediaSourceType)
        {
            ResetGraph();

            _mediaWindow = _mediaWindowHost.GetMediaWindow();
            _mediaWindow.MessageReceived += _mediaWindow_MessageReceived;

            _filterGraph = FilterGraphBuilder.BuildFilterGraph(source,
                                                               mediaSourceType,
                                                               _mediaWindow.Handle,
                                                               _preferredRenderer,
                                                               ReportError,
                                                               delegate(string message)
            {
                UserDecisionEventArgs args = new UserDecisionEventArgs(message);
                OnPartialSuccess(args);
                return(args.Accept);
            });
            if (_filterGraph != null)
            {
                _mediaWindow.SetRendererInterfaces(
                    _filterGraph.Renderer is IVMRWindowless ? ((IVMRWindowless)_filterGraph.Renderer).VMRWindowlessControl : null,
                    _filterGraph.Renderer is IVMR9Windowless ? ((IVMR9Windowless)_filterGraph.Renderer).VMRWindowlessControl : null,
                    _filterGraph.Renderer is IEVR ? ((IEVR)_filterGraph.Renderer).MFVideoDisplayControl : null);

                _filterGraph.GraphError       += (sender, args) => ReportError(args);
                _filterGraph.PlayBackComplete += (sender, arges) =>
                {
                    if (_repeat)
                    {
                        if (_filterGraph.IsGraphSeekable)
                        {
                            SetCurrentPosition(0);
                        }
                        else // gonna have to think it over!
                        {
                            SetCurrentPosition(0);
                        }
                    }
                    else
                    {
                        StopGraph();
                    }
                };
                _filterGraph.ErrorAbort += (sender, args) =>
                {
                    ResetGraph();
                    ReportError(String.Format("{0} {1}", Resources.Resources.mw_error_occured,
                                              Resources.Resources.mw_play_aborted));
                };
                _filterGraph.FailedStreamsAvailable += OnFailedStreamsAvailableInternal;

                var dvdFilterGraph = _filterGraph as IDvdFilterGraph;
                if (dvdFilterGraph != null)
                {
                    dvdFilterGraph.ModifyMenu        += (sender, args) => OnModifyMenu();
                    dvdFilterGraph.DiscEjected       += (sender, args) => ResetGraph();
                    dvdFilterGraph.InitSize          += (sender, args) => OnInitSize(false, true);
                    dvdFilterGraph.DvdParentalChange += (sender, args) => args.Raise(this, ref DvdParentalChange);
                }

                OnInitSize(true, true);
                IsMuted = IsMuted; // this resets the volume

                return(!_autoPlay || ResumeGraph());
            }
            else
            {
                CleanUpMediaWindow();
                return(false);
            }
        }