Joe Lu
Joe Lu

Reputation: 2370

how to play specific track in background audio playback for windows phone 8?

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

Answers (2)

Joe Lu
Joe Lu

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

user523650
user523650

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

Related Questions