【问题标题】:Playing buffer, windows phone 8播放缓冲区,windows phone 8
【发布时间】:2014-11-02 11:20:01
【问题描述】:

我尝试在 Windows Phone 应用中播放音频缓冲区。

        byte[] buffer = new byte[44100 * 2 * 5];

        float t = 0;
        for (int i = 0; i < 44100 * 2 * 5; i += 2)
        {
            short val = (short)(Math.Sin(t * 2 * Math.PI * 440) * short.MaxValue);
            buffer[i] = (byte)(val & 0xFF);
            buffer[i + 1] = (byte)(val >> 8);
            t += 1 / 44100.0f;
        }

        sf = new SoundEffect(buffer, 44100, AudioChannels.Mono);

        // Play.
        sf.Play();

我得到错误: Microsoft.Xna.Framework.ni.dll 中出现了“System.InvalidOperationException”类型的第一次机会异常 Microsoft.Xna.Framework.ni.dll 中出现“System.InvalidOperationException”类型的异常,但未在用户代码中处理

请帮忙!

【问题讨论】:

    标签: windows-phone-8


    【解决方案1】:

    您需要拨打FrameworkDispatcher.Update

    与此处相同的答案应该有效: Playing a sound from a generated buffer in a Windows phone app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-28
      • 2011-10-31
      • 2013-11-22
      • 1970-01-01
      相关资源
      最近更新 更多