Reputation: 2370
i need to create several buttons, and each of them will start playing different mp3 tracks on background audio playback template, the tutorial that i found only tells me how to go next track or previous track, not play specific track on a button click, pls help
this is the msdn tutorial link for background audio playback development http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202978(v=vs.105).aspx
tks in advance
Upvotes: 1
Views: 802
Reputation: 2370
Found a solution from msdn:
You use the BackgroundAudioPlayer.Instance.Track property to change them. once you set the track, wait for the track ready player state changed to play it.
Upvotes: 1
Reputation:
Try this:
var stream = Application.GetResourceStream(<uri to file>);
var effect = SoundEffect.FromStream(stream.Stream);
var soundInstance = effect.CreateInstance();
FrameworkDispatcher.Update();
soundInstance.Play();
Upvotes: 0