Question

In Windows Phone project I can play music in background using:

Xaml:

<MediaElement x:Name="mediaplayer"/>

C#:

 mediaplayer.Source = new Uri("Woodkid_IRON_AssassinsCreed.mp3", UriKind.Relative);
 mediaplayer.Play();

But in msdn Microsoft says this: http://msdn.microsoft.com/en-us/library/hh202978%28v=vs.92%29.aspx

What is the difference? Thanks.

Was it helpful?

Solution

Your example will play music, but it will not play "background" music. Background audio means that if you leave the app, the music will continue to play. With your example, if you leave the app, the music will stop.

OTHER TIPS

The basic difference is that MediaElement is an actual control which can be rendered to the page, but it will not play music as a background task. Depending on your requirements, you can use either, but BackgroundAudioPlayer is the only way to play music in the background while MediaElement can provide music while you are on the page that contains the MediaElement.

EDIT: Or what Shawn says above! :P

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top