I have a problem with the fact that the changes I make with my applications are not updated in my ApplicationSettings settings for AudioPlayerAgents, which should be the same ?!
My program looks like this:
In my MainPage.xaml.cs in OnNavigatedTo I create two arrays of audio files
Audio[] aud = new Audio[2]; Audio[] aud1 = new Audio[2]; aud[0] = new Audio(new Uri("1.mp3", UriKind.Relative), "Test1", "Test1", new Uri("Images/Covers/0000000018724345_256x256_large.jpg", UriKind.Relative)); aud[1] = new Audio(new Uri("2.mp3", UriKind.Relative), "Test2", "Test2", new Uri("Images/Covers/0000000018698018_256x256_large.jpg", UriKind.Relative)); aud1[0] = new Audio(new Uri("3.mp3", UriKind.Relative), "Test3", "Test3", new Uri("Images/Covers/0000000018465020_256x256_large.jpg", UriKind.Relative)); aud1[1] = new Audio(new Uri("http://traffic.libsyn.com/wpradio/WPRadio_29.mp3", UriKind.Absolute), "Episode 29", "Windows Phone Radio", new Uri("Images/Covers/0000000018844939_256x256_large.jpg", UriKind.Relative));
Then I save one of these arrays in ApplicationSettings
IsolatedStorageSettings.ApplicationSettings["tracklist"] = aud; IsolatedStorageSettings.ApplicationSettings.Save();
Then I close and run BackgroundAudioPlayer.
BackgroundAudioPlayer.Instance.Close(); BackgroundAudioPlayer.Instance.Play();
In my AudioPlayer, I load previously saved ApplicationSettings that work fine.
Audio[] aud; IsolatedStorageSettings.ApplicationSettings.TryGetValue<Audio[]>("tracklist", out aud);
But when I later want to replace ApplicationSettings in my MainPage.xaml.cs with another array
IsolatedStorageSettings.ApplicationSettings["tracklist"] = aud1; IsolatedStorageSettings.ApplicationSettings.Save();
And load the values again in my AudioPlayer, are there still old values in my ApplicationSettings, and should AudioPlayerAgent and MainPage use the same ApplicationSettings permissions? In fact, the first time it is saved and available for AudioPlayerAgent, so what am I missing?
My Audio class is as follows
[DataContractAttribute] public class Audio { [DataMember] public Uri TrackUrl { get; set; } [DataMember] public string Title { get; set; } [DataMember] public string Artist { get; set; } [DataMember] public Uri CoverURL { get; set; } public Audio(Uri trackUrl, string title, string artist, Uri coverUrl) { TrackUrl = trackUrl; Title = title; Artist = artist; CoverURL = coverUrl; } }