C# Class Tsukikage.DirectShow.ExampleMoviePlayer

DirectShowのSampleGrabberGraph を使ってメディアファイルを再生するサンプル。 SampleGrabberを使うメリットは、ビデオもオーディオもデコード後のデータのポインタが得られることで、 Marshal.Copyなどでbyte[]にコピーするなり、unsafeコンテキストを使うなりで手軽に加工することができる。 ゲームアプリなどではDynamicTextureに転送することで簡単にムービーテクスチャを作ることもできる。 VMR9を使った方がパフォーマンスが出るが、Device LostがOSのバージョンごとに挙動が違ったりで対応しきれない。 カスタムレンダラを作るのが最良の方法なのだろうけれど、C#のみでカスタムレンダラを作るのは至難の業。 Enter:開く, Space:再生/一時停止, Escape:停止 ←/→:5秒シーク
Inheritance: System.Windows.Forms.Form
Datei anzeigen Open project: ttsuki/ttsuki

Public Methods

Method Description
ExampleMoviePlayer ( ) : System
SampleMain ( ) : void

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Clean up any resources being used.

Private Methods

Method Description
CloseMedia ( ) : void

グラフとビデオバッファとオーディオデバイスを解放する。

ExampleMoviePlayer_FormClosing ( object sender, FormClosingEventArgs e ) : void

閉じられる。ファイルを閉じる。

ExampleMoviePlayer_KeyDown ( object sender, KeyEventArgs e ) : void

キーが押された。各種操作。

ExampleMoviePlayer_Paint ( object sender, PaintEventArgs e ) : void

画面を更新すべき。

ExampleMoviePlayer_Shown ( object sender, EventArgs e ) : void

ウィンドウが表示された。開くダイアログを開く。

InitializeComponent ( ) : void

Required method for Designer support - do not modify the contents of this method with the code editor.

Main_ ( ) : void
graph_AudioFrame ( double sampleTime, IntPtr pFrame, int bufferSize ) : void

オーディオデータが到着。waveOutに書き込む。

graph_VideoFrame ( double sampleTime, IntPtr pFrame, int bufferSize ) : void

ビデオフレームが到着。videoBufferをロックして転送する。

openMediaFileDialog_FileOk ( object sender, CancelEventArgs e ) : void

開くダイアログでOKが押された。ファイルを開いて再生する。

timer1_Tick ( object sender, EventArgs e ) : void

一定時間毎に画面更新しておく。(オーディオファイルや、一時的に0FPSになるビデオファイルも存在する)

Method Details

Dispose() protected method

Clean up any resources being used.
protected Dispose ( bool disposing ) : void
disposing bool true if managed resources should be disposed; otherwise, false.
return void

ExampleMoviePlayer() public method

public ExampleMoviePlayer ( ) : System
return System

SampleMain() public static method

public static SampleMain ( ) : void
return void