* U K I Y A H O N P O *
Nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura,
che la diritta via era smarrita.
リロード   新規 下位ページ作成 編集 凍結 差分 添付 コピー 名前変更   ホーム 一覧 検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
浮子屋商店もよろしく。

C#コード断片/1.1/メモリからWAVを再生

Top > C#コード断片 > 1.1 > メモリからWAVを再生

事前にメモリ内にByte配列としてWAVデータが読み込まれているものとする。

C#コード断片/1.1/EXEに埋め込んだリソースをバイナリで取得する等で確保したメモリに対して実行。

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
[DllImport("winmm.dll",CallingConvention=CallingConvention.Winapi,EntryPoint="PlaySound")]
private static extern int PlaySound(byte[] pszSound, int hmod, int flags);
private static int    SND_SYNC            = 0x0000;/* play synchronously (default) */
private static int    SND_ASYNC           = 0x0001;/* play asynchronously */
private static int    SND_NODEFAULT       = 0x0002;/* silence (!default) if sound not found */
private static int    SND_MEMORY          = 0x0004;/* pszSound points to a memory file */
private static int    SND_LOOP            = 0x0008;/* loop the sound until next sndPlaySound */
private static int    SND_NOSTOP          = 0x0010;/* don't stop any currently playing sound */
private static int    SND_NOWAIT            = 0x2000;/* don't wait if the driver is busy */
private static int    SND_ALIAS            = 0x10000;/* name is a registry alias */
private static int    SND_ALIAS_ID        = 0x110000;/* alias is a pre d ID */
private static int    SND_FILENAME        = 0x20000;/* name is file name */
private static int    SND_RESOURCE        = 0x40004;/* name is resource name or atom */
private static int    SND_PURGE           = 0x0040;/* purge non-static events for task */
private static int    SND_APPLICATION     = 0x0080;/* look for application specific association */
 
PlaySound(buf,0,SND_MEMORY|SND_LOOP|SND_ASYNC);
  • これは.NET2.0ではMedia名前空間の機能でサポートされている筈。後で調べてみる。 -- 浮子屋 2006-02-21 22:35:26 (火)

このページの最終更新日: 2006/03/03 17:26:24 JST (6628d)
このページのトラックバックURL: http://ukiya.sakura.ne.jp/index.php?tb_id=b8e50c441ecf1029451709ae1b6d91a8