Monogame:不玩WAV [英] Monogame: WAV not playing

查看:49
本文介绍了Monogame:不玩WAV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是MonoGame 3.4,我正在VS2013中使用它.我正在使用mgcb和我的纹理相同的方式来编译WAV文件. MGCB可以正常工作,但是使用SoundEffect类播放声音时,它什么也不播放.没有异常,SoundEffect.Play()函数返回true,但是我听不到任何声音.这是我的代码:

This is MonoGame 3.4 and I'm using it through VS2013. I'm compiling my WAV file using mgcb the same way as my textures. MGCB works fine, but when it comes to playing a sound using SoundEffect class, it doesn't play anything. There is no exception and SoundEffect.Play() function returns true, but I can't hear anything. Here's my code:

正在加载:

JumpSound = content.Load<SoundEffect>("SpinJump"); 

播放:

var Ins = JumpSound.CreateInstance();
Ins.Volume = 1f;
Ins.Play();

在XNA项目中,完全相同的代码可以播放声音.这是已知的错误还是什么?

The very same code plays the sound just fine in XNA project. Is this a known bug or something?

推荐答案

我遇到了完全相同的问题.我的解决方案是重新安装DirectX.由于某种原因,这有所帮助.我正在运行Windows 10和VS 2015 Community Edition.我还安装了XNA,运行相同的代码就可以了!

I had the exact same problem. My solution was to reinstall DirectX. For some reason this helped. I was running Windows 10 and VS 2015 Community Edition. I also had XNA installed where the same code was running just fine!

重新安装DirectX后( https://www.microsoft.com/zh-cn/download/details.aspx?id=35&84e4d527-1a2f-c70a-8906-a877ec4baada=1 ),SoundEffect类再次开始工作!

After reinstalling DirectX (https://www.microsoft.com/en-us/download/details.aspx?id=35&84e4d527-1a2f-c70a-8906-a877ec4baada=1) the SoundEffect class started working again!

希望这会有所帮助.

这篇关于Monogame:不玩WAV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆