Click here to Skip to main content
15,887,946 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to do something similar to the media player in windows phone 7 where the next several song is shown. What approach I would take to accomplish this?
but it only runs on a virtual machine, when I installed it on the phone, play only 1 song
Example: previous song previous song CURRENT SONG next song next song

my code currently like this:

int i;
public MainPage()
{
InitializeComponent();

var library = new MediaLibrary();
lstSongs.ItemsSource = library.Songs;

var timer = new DispatcherTimer { Interval = TimeSpan.FromTicks(333333) };
timer.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } }; timer.Start();
timer.Tick += new EventHandler(currentPosition_Tick);
}

void currentPosition_Tick(object sender, EventArgs e)
{
switch (MediaPlayer.State)
{
case MediaState.Playing:
if (MediaPlayer.PlayPosition >= MediaPlayer.Queue.ActiveSong.Duration)
{
MediaPlayer.Stop();
i += 1;
MediaLibrary mediaLibrary = new MediaLibrary();
MediaPlayer.Play(mediaLibrary.Songs[i]);
lstSongs.SelectedIndex = lstSongs.SelectedIndex + 1;

}
break;

case MediaState.Paused:
break;

case MediaState.Stopped:
break;
}

}

private void SongSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{

MediaLibrary mediaLibrary = new MediaLibrary();
MediaPlayer.Play(mediaLibrary.Songs[lstSongs.SelectedIndex]);

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900