2
votes

I am building a Windows Phone 8.1 RT App which runs MP3 files in Background task.

I followed the steps in the sample code shown here : http://code.msdn.microsoft.com/windowsapps/BackgroundAudio-63bbc319

When the app runs in the background, I would like to show the Album Artist & Song Title. Currently it just shows the file name.

enter image description here

1

1 Answers

2
votes

In SampleBackgroundAudioTask, there is a MyBackgroundAudioTask which is the background audio task used for playing music. There's an object of type SystemMediaTransportControls in that class called systemmediatransportcontrol.

SystemMediaTransportControls class enables your app to use the system media transport controls provided by Windows and update the media info that is displayed. There's a private method in MyBackgroundAudioTask responsible for updating the UVC (Universal Volume Control) when current track changes called UpdateUVCOnNewTrack. This uses the SystemMediaTransportControls.DisplayUpdater to set the MusicProperties. MusicProperties is of type MusicDisplayProperties and include properties such as the song title and the song artist.

This is how you set the song title and artist which gets shown in the UVC.

systemmediatransportcontrol.DisplayUpdater.MusicProperties.Title = "My lovely track";
systemmediatransportcontrol.DisplayUpdater.MusicProperties.Artist = "An awesome artist";
systemmediatransportcontrol.DisplayUpdater.Update();