加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 无法使用Monogame 3.2 for Windows 7 Desktop(DirectX)播

发布时间:2020-12-15 22:07:50 所属栏目:百科 来源:网络整理
导读:出于某种原因,我不能让Monogame通过SoundEffect或SoundEffectInstance播放任何声音. 通过解决方法,我可以播放歌曲,但仍然不是SoundEffects或SoundEffectInstances. 如果我通过“原生XNA”运行我的示例,一切正常. 我正在使用: 用于Windows桌面的Monogame 3.2
出于某种原因,我不能让Monogame通过SoundEffect或SoundEffectInstance播放任何声音.
通过解决方法,我可以播放歌曲,但仍然不是SoundEffects或SoundEffectInstances.

如果我通过“原生XNA”运行我的示例,一切正常.

我正在使用:
用于Windows桌面的Monogame 3.2(DirectX)
Windows 7的
Visual Studio Express 2013

例:

SoundEffect effect;
    SoundEffectInstance instance;
    Song song;

    protected override void LoadContent()
    {
        // Load sound,no errors and the objects get filled with data.
        effect = Content.Load<SoundEffect>("myWavFileAsSoundEffect"); // Loaded with ContentProcessor = "Sound Effect - XNA Framework" 
        song = Content.Load<Song>("myWavFileAsSong"); // Loaded with ContentProcessor = "Song - XNA Framework"
        instance = effect.CreateInstance();

        // Set volume to 100%,just in case
        SoundEffect.MasterVolume = 1.0f;
        MediaPlayer.Volume = 1.0f;
        instance.Volume = 1.0f;
    }

    protected override void Update(GameTime gameTime)
    {
        if (Keyboard.GetState().IsKeyDown(Keys.Space))
        {
            // Play instance. Nothing happens.
            instance.Play();

            // Play effect. Nothing happens.
            bool success = effect.Play(1.0f,0.0f,0.0f);
            // success is true

            // Play song.
            try
            {
                // Error
                // HRESULT: [0x80004002],Module: [General],ApiCode: [E_NOINTERFACE/No such interface supported]
                MediaPlayer.Play(song);
            }
            catch (Exception)
            {
                // Play the song again
                // Plays fine
                MediaPlayer.Play(song);
            }
        }


        base.Update(gameTime);
    }

有谁知道什么可能是错的?为什么我不能播放任何SoundEffects或SoundEffectInstances?

解决方法

我有完全相同的问题但在Windows 10上.我的解决方案是重新安装Directx.
Webinstaller: https://www.microsoft.com/en-us/download/details.aspx?id=35&84e4d527-1a2f-c70a-8906-a877ec4baada=1

希望这可以帮助

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读