Search code examples
c#windows-phone-8audio-playerbackground-musicbackground-audio

Play Certain Track With BackgroundAudioAgent Issue


I am having an isssue about playing a certain audio among List which is being played on background. Is there any way to pass the data from app to background audio agent and, let say, play the 5th audio like Spotify does.

The sample I am working on

Another version

There are some information about passing data from app to agent but, I couldn't implement what is being suggested.

Suggestion 1 enter image description here

Suggestion 2 enter image description here

Could you please help me to overcome this issue? Thanks in advance.


Solution

  • If you want to communicate by Tag property then you must be aware that, once AudioTrack has been created you will have to use BeginEdit as MSDN says:

    Once the track has been created using one of the AudioTrack constructors, then the BeginEdit() and EndEdit() methods must be used to update the object.

    For example changing Tag can look like this:

    AudioTrack track = BackgroundAudioPlayer.Instance.Track;
    track.BeginEdit();
    track.Tag = "New Tag";
    track.EndEdit();
    

    (accessing by a reference is needed here).