I noticed that just about all audioplayers I can reach through code (XNA MediaPlayer and BackgroundAudioPlayer) need files at a special location - they just fail playing without any error message.
So I can copy the file to IsolatedStorage, now I need a normal path again (normal meaning one that fully qualifies it on the file system: an absolute path, so that I can use System.IO.File on it).
Is that possible, and if yes, how?
(I would like to give that path then to a Microsoft.Xna.Framework.Media.MediaPlayer, hoping that it can play from that location, since it seems not to be able to play from arbitrary locations.)
Have you looked at MediaElement? (System.Windows.Controls.MediaElement
) You can set the source of the control with an IsolatedStorageFileStream
:
using (var isoStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isoStorage.FileExists(strFilename))
{
IsolatedStorageFileStream isoAudioFile = IsolatedStorageFileStream(strFilename, FileMode.Open, FileAccess.Read, isoStorage);
medAudioPlayer.SetSource(isoAudioFile);
}
}
Where medAudioPlayer is your MediaElement.
Note: this is for Windows Phone 8.1 Silverlight apps. Not sure if it's available in Universal apps.