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


C# IBasicAudio.put_Volume方法代码示例

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


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

示例1: PlayMovieInWindow


//.........这里部分代码省略.........
            if (EVRControl == null)
            {
                //Ищем рендерер и отключаем соблюдение аспекта (аспект будет определяться размерами видео-окна)
                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.None));
                }
                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.None));
                    }
                }
            }

            // QueryInterface for DirectShow interfaces
            this.mediaControl = (IMediaControl)this.graphBuilder;
            this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
            this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
            this.mediaPosition = (IMediaPosition)this.graphBuilder;

            // Query for video interfaces, which may not be relevant for audio files
            this.videoWindow = (EVRControl == null) ? this.graphBuilder as IVideoWindow : null;
            this.basicVideo = (EVRControl == null) ? this.graphBuilder as IBasicVideo : null;

            // Query for audio interfaces, which may not be relevant for video-only files
            this.basicAudio = this.graphBuilder as IBasicAudio;
            basicAudio.put_Volume(VolumeSet); //Ввод в ДиректШоу значения VolumeSet для установки громкости

            // Is this an audio-only file (no video component)?
            CheckIsAudioOnly();
            if (!this.IsAudioOnly)
            {
                if (videoWindow != null)
                {
                    // Setup the video window
                    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);

                    //Определяем fps
                    double AvgTimePerFrame;
                    hr = basicVideo.get_AvgTimePerFrame(out AvgTimePerFrame);
                    DsError.ThrowExceptionForHR(hr);
                    fps = (1.0 / AvgTimePerFrame);
                }
                else if (EVRControl != null)
                {
                    //Определяем fps
                    DetermineEVRFPS();
                }

                //Ловим ошибку Ависинта
                IsAviSynthError = false;
开发者ID:MaksHDR,项目名称:xvid4psp,代码行数:67,代码来源:MainWindow.xaml.cs

示例2: Init

        public override void Init()
        {
            if (!isPlaying)
            {
                string Filename = "";
                float size = 0;
                double Max = 0;
                int volume = 0;

                graph = new FilterGraph() as IFilterGraph;
                media = graph as IMediaControl;
                eventEx = media as IMediaEventEx;
                igb = media as IGraphBuilder;
                imp = igb as IMediaPosition;
                master.form.Invoke((MethodInvoker)delegate()
                {
                    Filename = master.form.M_Filename.Text;
                    media.RenderFile(Filename);
                    size = (float)master.form.M_PrevSize.Value;
                    master.form.M_PrevSize.Enabled = false;
                    imp.get_Duration(out Max);
                    master.form.M_Seek.Maximum = (int)(Max);
                    master.form.M_Seek.Value = 0;
                    volume = master.form.M_Volume.Value;
                    span = (uint)(1000000.0f / master.form.M_CollectFPS);
                });
                graph.FindFilterByName("Video Renderer", out render);
                if (render != null)
                {
                    window = render as IVideoWindow;
                    window.put_WindowStyle(
                        WindowStyle.Caption | WindowStyle.Child
                        );
                    window.put_WindowStyleEx(
                        WindowStyleEx.ToolWindow
                        );
                    window.put_Caption("ElectronicBoard - VideoPrev -");

                    int Width, Height, Left, Top;
                    window.get_Width(out Width);
                    window.get_Height(out Height);
                    window.get_Left(out Left);
                    window.get_Top(out Top);
                    renderSize.Width = (int)(Width * size);
                    renderSize.Height = (int)(Height * size);
                    Aspect = (float)renderSize.Height / (float)renderSize.Width;
                    window.SetWindowPosition(Left, Top, renderSize.Width, renderSize.Height);

                    eventEx = media as IMediaEventEx;
                    eventEx.SetNotifyWindow(master.form.Handle, WM_DirectShow, IntPtr.Zero);
                    media.Run();
                    foreach (Process p in Process.GetProcesses())
                    {
                        if (p.MainWindowTitle == "ElectronicBoard - VideoPrev -")
                        {
                            renderwindow = p.MainWindowHandle;
                            break;
                        }
                    }
                    isPlaying = true;
                    iba = media as IBasicAudio;
                    iba.put_Volume(volume);

                    //master.form.checkBox3_CheckedChanged(null, null);
                    master.Start();
                }
            }
        }
开发者ID:Surigoma,项目名称:Electronicboard,代码行数:68,代码来源:Movie.cs

示例3: PlayMovieInWindow


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

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

            if (EVRControl == null)
            {
                //Ищем рендерер и отключаем соблюдение аспекта (аспект будет определяться размерами видео-окна)
                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.None));
                }
                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.None));
                    }
                }
            }

            // QueryInterface for DirectShow interfaces
            this.mediaControl = (IMediaControl)this.graphBuilder;
            this.mediaEventEx = (IMediaEventEx)this.graphBuilder;
            this.mediaSeeking = (IMediaSeeking)this.graphBuilder;
            this.mediaPosition = (IMediaPosition)this.graphBuilder;

            // Query for video interfaces, which may not be relevant for audio files
            this.videoWindow = (EVRControl == null) ? this.graphBuilder as IVideoWindow : null;
            this.basicVideo = (EVRControl == null) ? this.graphBuilder as IBasicVideo : null;

            // Query for audio interfaces, which may not be relevant for video-only files
            this.basicAudio = this.graphBuilder as IBasicAudio;
            basicAudio.put_Volume(-(int)(10000 - Math.Pow(Settings.VolumeLevel, 1.0 / 5) * 10000)); //Громкость для ДиректШоу

            // Is this an audio-only file (no video component)?
            CheckIsAudioOnly();
            if (!this.isAudioOnly)
            {
                //Определяем аспект, если он нам не известен
                if (in_ar == 0)
                {
                    MediaInfoWrapper media = new MediaInfoWrapper();
                    media.Open(filepath);
                    in_ar = media.Aspect;
                    media.Close();
                }

                if (videoWindow != null)
                {
                    // Setup the video window
                    hr = this.videoWindow.put_Owner(this.source.Handle);
                    DsError.ThrowExceptionForHR(hr);

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

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

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

            this.Focus();

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

            this.currentState = PlayState.Running;
            SetPauseIcon();

            double duration = 0.0;
            hr = mediaPosition.get_Duration(out duration);
            DsError.ThrowExceptionForHR(hr);
            slider_pos.Maximum = duration;

            //Запускаем таймер обновления позиции
            if (timer != null) timer.Start();
        }
开发者ID:BrunoReX,项目名称:xvid4psp,代码行数:101,代码来源:DVDImport.xaml.cs


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