VideoとAudioに対するSampleGrabberとNullRendererによるデコードグラフを提供します。
Inheritance: GraphBase
Exemplo n.º 1
0
        /// <summary>
        /// 開くダイアログでOKが押された。ファイルを開いて再生する。
        /// </summary>
        private void openMediaFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            // 前に再生していたものを閉じる
            CloseMedia();

            // ファイル名
            string path = System.IO.Path.GetFullPath(openMediaFileDialog.FileName);

            try
            {
                // 読み込む
                graph = new SampleGrabberGraph(path);
                //graph.RegisterToROT = true; // trueにするとgraphedit.exeから見えるようになる。
                graph.Load();
            }
            catch
            {
                // error...
                graph.Dispose();
                graph = null;
                MessageBox.Show("Error occured.");
                return;
            }

            // メディアと同じ形式でオーディオデバイスを開く
            if (graph.HasAudio)
            {
                waveOut           = new WinMM.WaveIO.WaveOut(WinMM.WaveIO.WaveOut.WaveMapper, graph.AudioSamplePerSec, graph.AudioBitsPerSample, graph.AudioChannels);
                graph.AudioFrame += graph_AudioFrame;
            }

            // メディアと同じサイズでビデオバッファを作る
            if (graph.HasVideo)
            {
                this.ClientSize   = graph.VideoSize;
                videoBuffer       = new Bitmap(graph.VideoSize.Width, graph.VideoSize.Height, PixelFormat.Format32bppArgb);
                graph.VideoFrame += graph_VideoFrame;
            }

            // 再生。
            if (graph != null)
            {
                graph.Play();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// グラフとビデオバッファとオーディオデバイスを解放する。
        /// </summary>
        private void CloseMedia()
        {
            if (graph != null)
            {
                graph.Dispose();
                graph = null;
            }

            if (videoBuffer != null)
            {
                videoBuffer.Dispose();
                videoBuffer = null;
            }

            if (waveOut != null)
            {
                waveOut.Close();
                waveOut = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// グラフとビデオバッファとオーディオデバイスを解放する。
        /// </summary>
        private void CloseMedia()
        {
            if (graph != null)
            {
                graph.Dispose();
                graph = null;
            }

            if (videoBuffer != null)
            {
                videoBuffer.Dispose();
                videoBuffer = null;
            }

            if (waveOut != null)
            {
                waveOut.Close();
                waveOut = null;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 開くダイアログでOKが押された。ファイルを開いて再生する。
        /// </summary>
        private void openMediaFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            // 前に再生していたものを閉じる
            CloseMedia();

            // ファイル名
            string path = System.IO.Path.GetFullPath(openMediaFileDialog.FileName);

            try
            {
                // 読み込む
                graph = new SampleGrabberGraph(path);
                //graph.RegisterToROT = true; // trueにするとgraphedit.exeから見えるようになる。
                graph.Load();
            }
            catch
            {
                // error...
                graph.Dispose();
                graph = null;
                MessageBox.Show("Error occured.");
                return;
            }

            // メディアと同じ形式でオーディオデバイスを開く
            if (graph.HasAudio)
            {
                waveOut = new WinMM.WaveIO.WaveOut(WinMM.WaveIO.WaveOut.WaveMapper, graph.AudioSamplePerSec, graph.AudioBitsPerSample, graph.AudioChannels);
                graph.AudioFrame += graph_AudioFrame;
            }

            // メディアと同じサイズでビデオバッファを作る
            if (graph.HasVideo)
            {
                this.ClientSize = graph.VideoSize;
                videoBuffer = new Bitmap(graph.VideoSize.Width, graph.VideoSize.Height, PixelFormat.Format32bppArgb);
                graph.VideoFrame += graph_VideoFrame;
            }

            // 再生。
            if (graph != null) graph.Play();
        }