Play Media from Isolated Storage in Windows Phone 8

Here’s a custom function that can be used to play media from isolated storage in Windows Phone 8 app. The code snippet also uses a global media element which enables background media in multiple pages in Windows Phone app. The media doesn’t keep playing when the app is closed but it continues playing even if you navigate away from that page. Here’s the function,

Just pass the name location of your media file as parameter to use this function. Declare AppMediaElement either at the top of the page or use this tutorial as a reference to enable background media in multiple pages.
How to enable Background audio in multiple pages in Windows phone application