locked
There is no way to play game music in C# Windows Phone 8.1 ?

    Question

  • How can one make a game in C# even with WebView if there is no way to play music (from compressed format like mp3, ogg, wma, etc) ? MediaPlayer doesn't work, as whenever you play sounds on top it gets choppy and stops soon, DirectX is C++ (even with that I found no code sample to play mp3 or such), XNA is discontinued, and WebView music also doesn't work on many devices I tested also it doesn't loop.



    • Edited by Ozdy Friday, March 20, 2015 5:58 PM
    Friday, March 20, 2015 5:49 PM

Answers

  • Hello,

    If you use the MediaElement make sure to set the AudioCategory to GameMedia.

    -James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    • Marked as answer by Ozdy Sunday, March 22, 2015 8:01 AM
    Friday, March 20, 2015 7:47 PM
    Moderator

All replies

  • MediaElement is the way you play music in a Windows Store app.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, March 20, 2015 7:27 PM
    Moderator
  • Hello,

    If you use the MediaElement make sure to set the AudioCategory to GameMedia.

    -James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    • Marked as answer by Ozdy Sunday, March 22, 2015 8:01 AM
    Friday, March 20, 2015 7:47 PM
    Moderator
  • Thank you, it seems to work when I create a XAML element MediaElement, it didn't seem to work (interruptions and no looping) when I created it only from C# code.

    Sunday, March 22, 2015 8:00 AM
  • Hello,

    This is correct. The MediaElement must be part of the XAML visual tree. You can add it to the visual tree by declaring it in markup or adding it programmatically.

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Monday, March 23, 2015 8:28 PM
    Moderator