概要
cscの作法、調べてみた。
練習問題、やってみた。
練習問題
directshowlibでwmvファイルを再生せよ。
サンプルコード
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using DirectShowLib;
namespace App
{
class Program {
static void Main(string[] args) {
Console.WriteLine("start");
IGraphBuilder pGraphBuilder = (DirectShowLib.IGraphBuilder) new FilterGraph();
IMediaControl pMediaControl = (DirectShowLib.IMediaControl) pGraphBuilder;
IMediaEvent pMediaEvent = (DirectShowLib.IMediaEvent) pGraphBuilder;
pMediaControl.RenderFile(@"test1.wmv");
IVideoWindow pVideoWindow = (DirectShowLib.IVideoWindow) pGraphBuilder;
pVideoWindow.put_FullScreenMode(OABool.True);
pMediaControl.Run();
EventCode code;
pMediaEvent.WaitForCompletion(1000, out code);
pVideoWindow.put_FullScreenMode(OABool.False);
Marshal.ReleaseComObject(pGraphBuilder);
pGraphBuilder = null;
Marshal.ReleaseComObject(pMediaControl);
pMediaControl = null;
Marshal.ReleaseComObject(pMediaEvent);
pMediaEvent = null;
Console.WriteLine("end");
}
}
}
以上。