프로그래밍
[C#.net] 초간단 Sound File Play 하기
건우아빠유리남편
2010. 10. 20. 13:32
반응형
API를 모셔와야지
winmm.DLL 을 사용하면 간단하다.
↑ 멀티미디어 관련 기능을 모아놓은 DLL
간단히 클래스 정의해보앗슴
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace 냐옹이네
{
public class SoundHelper
{
#region API DLL Import And Define
[System.Runtime.InteropServices.DllImport("winmm.DLL", CharSet = CharSet.Auto)]
private static extern bool PlaySound(string szSound, int hMod, PlaySoundFlags flags);
{
public class SoundHelper
{
#region API DLL Import And Define
[System.Runtime.InteropServices.DllImport("winmm.DLL", CharSet = CharSet.Auto)]
private static extern bool PlaySound(string szSound, int hMod, PlaySoundFlags flags);
[System.Flags]
public enum PlaySoundFlags : int
{
SND_SYNC = 0x0000,
SND_ASYNC = 0x0001,
SND_NODEFAULT = 0x0002,
SND_LOOP = 0x0008,
SND_NOSTOP = 0x0010,
SND_NOWAIT = 0x00002000,
SND_FILENAME = 0x00020000,
SND_RESOURCE = 0x00040004
}
#endregion
public enum PlaySoundFlags : int
{
SND_SYNC = 0x0000,
SND_ASYNC = 0x0001,
SND_NODEFAULT = 0x0002,
SND_LOOP = 0x0008,
SND_NOSTOP = 0x0010,
SND_NOWAIT = 0x00002000,
SND_FILENAME = 0x00020000,
SND_RESOURCE = 0x00040004
}
#endregion
public static void PlaySound(string FilePath)
{
PlaySound(FilePath, 0, PlaySoundFlags.SND_ASYNC | PlaySoundFlags.SND_FILENAME);
}
}
}
반응형