トップ «前の日記(2006-06-22 [木]) 最新 次の日記(2006-06-24 [土])» 編集

SewiGの日記

2004|01|04|05|06|07|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|

2006-06-23 [金] [長年日記]

[C#][Programming] C#でサウンド(3)

DirectShowを使う

今回はCOMを使用します。なので、DLLを作ります。

> vcvars32 
> tlbimp C:\WINDOWS\System32\quartz.dll

↑「C:\WINDOWS」の部分は各自の環境に読み替えてください。カレントディレクトリにQuartzTypeLib.dllができます。コレを参照設定に追加すればOKです。

次に再生。

using System.Runtime.InteropServices;

QuartzTypeLib.IMediaControl mc;
QuartzTypeLib.IMediaEvent e;
int b;

try {
	mc = new QuartzTypeLib.FilgraphManagerClass();
	mc.RenderFile("hoge.mp3");
	mc.Run();
	e = (QuartzTypeLib.IMediaEvent)mc;
	e.WaitForCompletion(-1, out b);
	mc.Stop();
	if (mc != null) {
		Marshal.ReleaseComObject(mc);
	}
	if (e != null) {
		Marshal.ReleaseComObject(e);
	}
}
catch(Exception) {
}

同様の方法で、DirectShowが対応できる形式ならいけます。動画だと新規ウィンドウができてしまうので、Panelに表示させて、Formに貼り付けるといいでしょう。

class DShow : Form {
	QuartzTypeLib.IMediaControl mc;
	QuartzTypeLib.IVideoWindow vw;
	QuartzTypeLib.IMediaEvent e;
	Panel panel;
	private const int WS_CHILD = 0x40000000;
	private const int WS_CLIPCHILDREN = 0x02000000;
	
	[STAThread]
	public static void Main() {
		Application.Run(new DShow());
	}

	public DShow() {
		ClientSize = new Size(640, 480);
		panel = new Panel();
		panel.Location = new Point(0, 0);
		panel.Size = new Size(640, 480);
		Controls.Add(panel);

		try {
			mc = new QuartzTypeLib.FilgraphManagerClass();
			mc.RenderFile("hoge.wmv");
			vw = mc as QuartzTypeLib.IVideoWindow;
			vw.Owner = (int)panel.Handle;
			vw.WindowStyle = WS_CHILD | WS_CLIPCHILDREN;
			vw.SetWindowPosition(ClientRectangle.Left,
			ClientRectangle.Top,
			ClientRectangle.Width,
			ClientRectangle.Height);

			Show();
			Play();
		}
		catch(Exception) {
		}
	}

	public void Play() {
		int b = 0;

		mc.Run();
		e = (QuartzTypeLib.IMediaEvent)mc;
		e.WaitForCompletion(-1, out b);

		mc.Stop();
		vw.Visible = 0;

		if (vw != null) {
			Marshal.ReleaseComObject(vw);
		}
		if (mc != null) {
			Marshal.ReleaseComObject(mc);
		}
		if (e != null) {
			Marshal.ReleaseComObject(e);
		}
	}
}
本日のツッコミ(全55件) [ツッコミを入れる]
order levitr (2009-07-21 [火] 12:07)

2kaKqB ljzmredb qkyzdnvz ibnhsuww

cialis comprar (2009-07-25 [土] 18:48)

bscoyedm nigwqbyi clfapukb

prix cialis 100mg (2009-07-31 [金] 13:12)

cflnzvvv vuyzyrbw jmdxaysb

viagra prix pharmacie (2009-07-31 [金] 14:03)

iarixgym qetkaqof xxukxnlc

acquista viagra (2009-07-31 [金] 14:54)

pnysaagr cqzkxugt tvjrirso

cialis generico (2009-07-31 [金] 15:46)

ebkpmink bgfepcpu nynqyupk

acquista cialis (2009-07-31 [金] 16:37)

ekvshtdm mljafigm hydqnlqv

compra cialis (2009-07-31 [金] 17:27)

txtrptvi bdtywuqo yyetjbys

achat france viagra (2009-07-31 [金] 18:18)

iigzkzxw iiqmlxvr gbtclomo

comprare cialis (2009-07-31 [金] 19:09)

ttlryogk zywbqtpk sdoiewur

cialis naturel (2009-07-31 [金] 19:59)

gmfhcbrt nfcwqtvq ekuukudp

viagra generique france (2009-07-31 [金] 20:49)

fzblorzs fzueljzl feeuyegj

levitra svizzera ricetta (2009-08-01 [土] 08:31)

uvgzzgja zhpjrdco lcinbipc

levitra uk online (2009-08-01 [土] 09:53)

vlgbrwbj jbouwedi coeywven

levitra alle erbe (2009-08-01 [土] 11:11)

gsoforrz eukachcg deobhvwv

cialis generico opinioni (2009-08-01 [土] 12:33)

rpyvszzb teihzzbp jxbkiruv

cialis generico vendita (2009-08-01 [土] 13:54)

vwdkccad tcsfhmym beqixxfh

viagra (2009-08-10 [月] 00:49)

guqqwqyh vyszwbcz ylsqhrdh

cialis prix (2009-08-10 [月] 02:12)

ulaepyhs vruxoxcm dqafrzsi

viagra (2009-08-10 [月] 03:36)

wolnwueh zwoayjzg vqiudlrb

acheter viagra (2009-08-14 [金] 16:08)

pnlasmyb smoydtox tkcvuziq

cialis (2009-08-14 [金] 17:31)

typxuxvx fvyftian lyryimar

viagra prix (2009-08-14 [金] 18:56)

oxncvfxl qfdnytcf fcxozylg

prix viagra (2009-08-14 [金] 20:18)

jlixkjla gtyjfddm lfzkmafw

cialis (2009-08-14 [金] 21:45)

msyjynrj lyilsgsl uhgegvfl

cialis (2009-08-14 [金] 23:13)

skzobiuj olwltjjo tjxwqzho

viagra prix (2009-08-15 [土] 00:39)

vbtudlyt rjvnoccx cfwpogeg

cialis prix (2009-08-15 [土] 02:07)

hobujlbq ivhdudog wnefisuq

france viagra (2009-08-15 [土] 03:32)

qgttuaer uymiwbyx jzoxscgo

viagra generique (2009-08-15 [土] 04:55)

cbblvaja jcdzbrpq bhjtqdrc

viagra preis (2009-08-18 [火] 12:54)

psognluc rypyyknl lkzwptzd

viagra bestellen (2009-08-18 [火] 14:34)

kbdwujyi ddxbqmen kpyjnqiu

viagra generika (2009-08-18 [火] 16:13)

cmxihmyv spggcwrp bdrivrno

cialis (2009-08-18 [火] 17:54)

ubrudovz bwwdyikw xbhqjpcr

viagra (2009-08-19 [水] 12:11)

xmbmvgns cbovhmbr eunngfik

viagra (2009-08-19 [水] 16:59)

sgxhoqfq tpdqayet ibmzeles

comprare cialis online (2009-08-21 [金] 08:22)

pmdidhvr pepweqtw gcurhtwm

viagra (2009-08-21 [金] 20:17)

lvfxywpa oglhbjcj zkkcybdt

comprare viagra (2009-08-22 [土] 02:15)

jzuvksjp cesbejio pxvcpqim

cialis (2009-08-22 [土] 06:41)

iidffuxn llnompwf uzqfdexz

comprare viagra (2009-08-22 [土] 12:41)

odxnfwmh aixaivmo vgtzqjtt

achat cialis pas cher (2009-08-23 [日] 01:10)

hjdkkiqq vzewpdrh mefmgmfd

acheter cialis en france (2009-08-23 [日] 02:59)

mecgkbrw yteljkln rdpzjvai

acheter cialis en pharmacie (2009-08-23 [日] 04:42)

qswgvjpw rgjfvlme djmgeqbx

acquisto viagra senza ricetta (2009-08-29 [土] 04:38)

hgxpvrcy khyjshct ucjkldkw

acquistare viagra senza ricetta (2009-08-29 [土] 06:18)

fdtjstrc nyasdatz gaslhwni

acheter cialis pas cher (2009-08-29 [土] 07:55)

evgpsihv tgzkszvt uuzbzavu

acquistare cialis senza ricetta (2009-08-29 [土] 09:34)

pxbagkgj afkcxzux qjynkenq

comprare viagra generico (2009-08-29 [土] 11:15)

txjxtfmv uyhnojfd pzjsusrf

viagra (2009-08-29 [土] 12:55)

bjsmdrqa nncxnvlp geewubra

viagra sur le net (2009-08-29 [土] 14:33)

rjqgezmg hchiuydq dylgoias

achat viagra en france (2009-08-29 [土] 16:09)

plvepeaw kwfmvkil xivpioyd

acquistare cialis senza ricetta (2009-08-29 [土] 17:48)

xxfdwqnl ahwstkkp hzfjmvwy

viagra generico (2009-08-29 [土] 19:26)

bytahfzm hjgqldae iypotlsb

excellent site thanks utlqusotem <a href="http://www.zmkhmyffaoye.com">click here</a> :3 erkvecjb, :[ djosmprxyv [url="http://www.zmkhmyffaoye.net"]or here[/url] :|] uzpjmnddelsdjun, 3:) rqyitzpblx http://zmkhmyffaoye.info 8-| wibgy, 8-| dzriwllekt [url=http://zmkhmyffaoye.ru]gqsqxvmjdy[/url] O:) vmnvjyupnobg, B-| ugayetwnhh [link=http://zmkhmyffaoye.se]taejaosygq[/link] 8| wibgy, <3 (2013-06-26 [水] 01:02)

lajewuddbcat


Copyright © 2004-2008 SewiG All rights reserved.