locked
XAudio2SoundPlayer can't play anything

    Question

  • Hello. I'm trying to make a simple game for the new Metro UI.

    I want to play some music in my game so I looked into the XAudio2 audio file playback sample. It works well, but when I try to put there my own wave file, it always throws an exception. I tried to convert the file in various applications with different settings and I also tried some other wave files but it never works. Could someone help me please? :(

    Thank you in advance.

    Sunday, July 1, 2012 11:07 AM

Answers

  • Hello,

    I would suggest you to check if the audio file is in the special folder. Sometimes, the file may miss in that folder. For example, the wave file should be in XAudio2 audio file playback sample\C++\Debug\BasicSound\AppX\Media for that sample code.

    On the other hand, you can use try-catch block to get more error message. Maybe this is not caused by the file miss.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Neme112 Thursday, July 5, 2012 5:13 PM
    Monday, July 2, 2012 7:56 AM

All replies

  • OK, I'm sorry, I copied and modified some code from the marble maze game example (can I?) for audio and it works perfectly, although I don't need any special sound effects since my game isn't 3D.
    Sunday, July 1, 2012 7:13 PM
  • Hello,

    I would suggest you to check if the audio file is in the special folder. Sometimes, the file may miss in that folder. For example, the wave file should be in XAudio2 audio file playback sample\C++\Debug\BasicSound\AppX\Media for that sample code.

    On the other hand, you can use try-catch block to get more error message. Maybe this is not caused by the file miss.

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Neme112 Thursday, July 5, 2012 5:13 PM
    Monday, July 2, 2012 7:56 AM
  • Thanks for answering. I checked the files, both of them were in the same directory and included in the project. I also tried to rename the original file and it worked but it has never worked with any other wave file. But it doesn't matter now for me, as I said I solved it by using code from another sample.
    • Edited by Neme112 Thursday, July 5, 2012 5:14 PM
    Thursday, July 5, 2012 5:13 PM