将 WindowsMediaPlayer 设置为自动运行 C# Windows 窗体
大家好,我正在以 Windows 形式构建我的第一个 RPG 游戏。 我目前正在尝试设置在启动时运行并且不会停止的默认背景音乐。 如果我将 axWindowsMediaPlayer 设置为可见并按播放,那么它的运行不会出现任何问题:
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"MyMusic\\ff3.mp3";
}
它是点击事件,但我可以找到任何“启动事件”。 我在某处读到默认 axWindowsMediaPlayer.settings.autorun 是 true,但只是为了确保我将该行添加到我的加载事件中:
private void Form1_Load(object sender, EventArgs e)
axWindowsMediaPlayer1.settings.autoStart = true;
但启动时仍然没有声音有什么想法吗?
Hi i'm building my first RPG game in windows form.
I'm currently trying to set a default background music that runs on boot and doesn't stop.
If i set the axWindowsMediaPlayer to visible and press play it runs without any problems with that simple line :
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = @"MyMusic\\ff3.mp3";
}
Its the click event but I can find any "On boot event".
I've read somewhere that the default axWindowsMediaPlayer.settings.autorun was true but just to make sure I added that line into my load event :
private void Form1_Load(object sender, EventArgs e)
axWindowsMediaPlayer1.settings.autoStart = true;
But still no sound on boot any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不使用 SoundPlayer 类?如果您正在构建游戏,那么这比您的解决方案更好。因此,您可以通过编写以下代码来加载声音文件:
然后您可以在需要时
Play()
和Stop()
播放声音。编辑:
在您的情况下:
PS:请记住,您必须将 .mp3 文件转换为 .wav
Why don't you use SoundPlayer Class? If you are building a game it's better this than your solution. So you can load your sound file writing this code:
Then you can
Play()
andStop()
your sound when you want.EDIT:
In your case:
PS: Remember that you have to convert your .mp3 files to .wav