1

Is there any way to comunicate directly with the AudioPlaybackAgent in windows phone 7 with out having to write a file to disk(Isolated Storage/DB).

Ideally I would want to expose a property or method that takes an object.

If no i would be happy with a string.

abe
  • 4,046
  • 6
  • 29
  • 33

1 Answers1

1

Due to the way that the agents are executed there's no way to call methods on the agent directly. Inter-process comms is not directly supported.

The only alternative to IsolatedStorage, for communication on the device, is to use a (SQL CE) database.
You could have both processes communicate via an external website but that's probably overkill and could cause issues if there was no network connection available.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
  • i am currently using isolated storage...it just seemed wasteful to have to write a file and read it to comunicate when setting a property or calling a method was all that is needed. i have been toying with using the tag in the track though...that comes with its own set of problem though :( – abe Feb 02 '12 at 08:44
  • Yep, been there and had the same problems. It's simplest when you can design for minimum comms between the two. I found fewest problems when just writing intial details for the agent to a file before starting the agent and then just leaving it to do it's thing separately. Relevant information for the app was inferred by the media player events and the agent didn't communicate back directly. – Matt Lacey Feb 02 '12 at 11:11
  • Don't forget to use a Mutex to ensure you're not trying to read /write the file at the same time from your app and from the agent. The main problem I've found with the AudioTrack.Tag is that it only exists if the audio player has a current track: which isn't always the case. – Paul Annetts Feb 02 '12 at 20:04
  • @PaulAnnetts I only write to the file before first starting the agent and only ever have the agent read the file. As the agent isn't running when the file is written there's no need. But yes, if both coudl be accessing the file(s) at the same time a mutex is necessary. – Matt Lacey Feb 02 '12 at 20:40
  • @PaulAnnetts thats a good tip thx unfortunately i need to read and right a lot – abe Feb 03 '12 at 09:50
  • @MattLacey i would like to only read once but unfortunately the app and the agent need to be in constant communication – abe Feb 03 '12 at 09:50
  • @abe but they can't always be. The agent may be running when the app isn't. It's much easier to have a design where constant communication isn't necessary. – Matt Lacey Feb 03 '12 at 10:15