Search code examples
silverlightwindows-phone-7.1mediaelement

Windows Phone 7.1 play recorded PCM/WAV audio


I'm working on a WP7.1 app that records audio and plays it back. I'm using a MedialElement to playback audio. The MediaElement works fine for playing MP4 (actually M4A files renamed) downloaded from the server. However, when I try to play a recorded file with or without the WAV RIFF header (PCM in both cases) it does not work. It gives me an error code 3001, which I cannot find the definition for anywhere.

Can anyone point me to some sample code on playing recorded audio in WP7.1 that does not use the SoundEffect class. Don't want to use the SoundEffect class because it's meant for short audio clips.

This is how I load the audio file:

using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
    using (Stream stream = storage.OpenFile(audioSourceUri.ToString(), FileMode.Open))
    {
        m_mediaElement.SetSource(stream);
    }
}

Solution

  • This playing code looks good. Issue have to be in storing code. BTW 3001 means AG_E_INVALID_FILE_FORMAT.