audiowindows-phone-8playbackamrsoundeffect

How to play amr file in Windows Phone 8?


From what I read, WP8 does support amr

However, I don't know how to play it.

  1. When using SoundEffect, I can't hear anything, maybe it's because SoundEffect supports wav only. Someone already asked here.
  2. I don't want to use BackgroundAudioPlayer or MediaPlayerLauncher, as they are overkill

Is there any workaround to play amr with SoundEffect, or is there a better API to play it ?

P/S: this amr file is record using WP8 API


Solution

  • You can play them using a MediaElement. Just add a MediaElement to your xaml file. Then set the source to your opened file. Something like:

    using(IsolatedStorageFileStream stream = appStorage.OpenFile(mFilename, FileMode.Open))
    {
         mMediaPlayer.SetSource(stream);
    }
    

    Then when you want to play the audio you call:

    mMediaPlayer.Play();