I am using IsolatedStorage to communicate with the Audio agent as below:
In each of my pages:
private void playButton_Click(object sender, RoutedEventArgs e)
{
if (PlayState.Playing == BackgroundAudioPlayer.Instance.PlayerState)
{
BackgroundAudioPlayer.Instance.Pause();
}
else
{
IsolatedStorageSettings.ApplicationSettings["BtnClicked"] = "1"; (or 2 or 3)
IsolatedStorageSettings.ApplicationSettings.Save();
BackgroundAudioPlayer.Instance.Stop();
BackgroundAudioPlayer.Instance.Play();
}
}
In my AudioPlayer.cs:
`case UserAction.Play:
if ((string)IsolatedStorageSettings.ApplicationSettings["BtnClicked"] == "1")
{
_playList = _playList1;
}
else if ((string)IsolatedStorageSettings.ApplicationSettings["BtnClicked"] == "2")
{
_playList = _playList;
}
else if ((string)IsolatedStorageSettings.ApplicationSettings["BtnClicked"] == "3")
{
_playList = _playList2;
}
PlayTrack(player); `
The problem however is that the "_playlist" variable isnt being updated except the first time. For example, if I Open Page 1, it selects _playlist1 correctly, but if I press "Back" then enter Page 2, it still selects _Playlist1. How can I force the variable to update every time I select a new page in my app? Also the rest of the code is very similar to: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202978%28v=vs.105%29.aspx