Windows Phone Background Audio current track is resetting

50 Views Asked by At

I am developing an WP8 app witch uses background audio agent. i have taken the background audio players sample. i have added the following method to audioplayer.cs

public static void playTrackAtIndex(int index)
    {
        currentTrackNumber = index;
        BackgroundAudioPlayer.Instance.Track = _playList[currentTrackNumber];
    }

after it is called the song at the specified index (let's say 5) will play, but when i pres skipnext in my ap or in the UVC currentTrackNumber is 0!. Please, any help is apreciated

1

There are 1 best solutions below

0
On BEST ANSWER

it turns out you don't have any control over the lifecycle of the background audio agent, so at any time it may be killed and then instanced by the foreground app or the Background audio player. So the only whey to make the agent work is to design it as it will always be killed and instanced (use sql lite or files with a lock, or always check what backgoundaudioplayer is playing when your agent is called, so your agent will "remember" where it was before getting killed