Search code examples
c#windows-phone-7background-audio

How to set/get a global variable between an AudioPlaybackAgent in WindowsPhone


I'm trying to make a small radius with the AudioPlaybackAgent as Microsoft show in their Samples In the sample we have a list of adudios:

private static List<AudioTrack> _playList = new List<AudioTrack>
{
    new AudioTrack(new Uri("http://000.000.000.000/radio1.mp3", UriKind.Absolute),
    "Radio 1", null, null, null, null, EnabledPlayerControls.Pause),

    new AudioTrack(new Uri("http://000.000.000.000/radio2.mp3", UriKind.Absolute), 
    "Radio 2", null, null, null, null, EnabledPlayerControls.Pause)
};

And here I would play the tracks:

private void PlayTrack(BackgroundAudioPlayer player)
{
    player.Track = _playList[VARIABLE];
}

On "VARIABLE" I want to put a variable that change depending the page I open in the main project. How I can do it? I tried a lot of things without exit. Thnks!!


Solution

  • The final answer: If you not need to use the audio in background you can simple use the media element, but if you want to use it you CAN NOT interactuate between the background agent and the main project with public variables, you must be work with Tag property of the audio player to store and get data, if this don't work you can try IsolatedStorge - Mutex.