winform 怎么插入背景音乐 5
1个回答
展开全部
#region 播放声音
public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand,
string lpstrReturnString, uint uReturnLength, uint hWndCallback);
public void PlayMusic()
{
mciSendString(@"open ""music.mp3"" alias temp_alias",
null, 0, 0);
mciSendString("play temp_alias repeat", null, 0, 0);
}
#endregion
public static uint SND_ASYNC = 0x0001; // play asynchronously
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand,
string lpstrReturnString, uint uReturnLength, uint hWndCallback);
public void PlayMusic()
{
mciSendString(@"open ""music.mp3"" alias temp_alias",
null, 0, 0);
mciSendString("play temp_alias repeat", null, 0, 0);
}
#endregion
追问
这个有点看不懂,如果用 soundplayer,怎么能打包到exe里面呢。
追答
这个就播放音乐的代码。mciSendString(@"open ""music.mp3"" alias temp_alias",null, 0, 0);
把其中的music.mp3换成你的音乐就可以了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询