0

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.

Burhan Ayan
  • 23
  • 1
  • 7
  • [AudioTrack](http://msdn.microsoft.com/EN-US/library/windowsphone/develop/microsoft.phone.backgroundaudio.audiotrack(v=vs.105).aspx) has `Tag` property which you can access from BAP and App, thus it can serve for communication between them. You can also use IsolatedStorageFile to pass some information - both BAP and App has access to same IsolatedStorage. All you have to do is to programm you Agent and main UI to use Tag/File. – Romasz Mar 05 '14 at 15:57
  • Good but exception throws when I try to set it. Here it is; [link](http://1drv.ms/1cxEoVi) – Burhan Ayan Mar 06 '14 at 15:22
  • I've added as an answer why you get Exception. It doesn't answer the question but hopefuly will help you a little to solve the problem. – Romasz Mar 06 '14 at 15:30

1 Answers1

0

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).

Romasz
  • 29,662
  • 13
  • 79
  • 154