2010-09-07 110 views
2

我將音頻文件放在一個.resx文件中。我想在我的應用程序中播放音頻。 然後如何從.resx文件和鋤頭獲得音頻路徑來播放音頻,當點擊按鈕 。可以舉一個例子。如何在Windows Mobile 6.0應用程序中播放音頻?

+0

什麼類型的音頻文件(WAV,MP3等)?使用什麼語言? – ctacke 2011-05-17 18:31:01

回答

2

用於播放聲音,你可以使用的P/Invoke

[DllImport("coredll.dll")] 
    public static extern int PlaySound(
     string szSound, 
     IntPtr hModule, 
     int flags); 


public enum PlaySoundFlags : int 
{ 
    SND_SYNC = 0x0,  // play synchronously (default) 
    SND_ASYNC = 0x1, // play asynchronously 
    SND_NODEFAULT = 0x2, // silence (!default) if sound not found 
    SND_MEMORY = 0x4,  // pszSound points to a memory file 
    SND_LOOP = 0x8,  // loop the sound until next sndPlaySound 
    SND_NOSTOP = 0x10,  // don't stop any currently playing sound 
    SND_NOWAIT = 0x2000, // don't wait if the driver is busy 
    SND_ALIAS = 0x10000, // name is a registry alias 
    SND_ALIAS_ID = 0x110000,// alias is a predefined ID 
    SND_FILENAME = 0x20000, // name is file name 
    SND_RESOURCE = 0x40004, // name is resource name or atom 
} 

爲了發揮你可以使用這個聲音。

PlaySound(@"notify.wav", IntPtr.Zero, 
(int) PlaySoundFlags.SND_FILENAME | PlaySoundFlags.SND_ASYNC); 
相關問題