This project has moved. For the latest updates, please go here.

Ok, I want to share my solution for autostart and continuous play

Jul 30, 2010 at 2:09 AM
1. MultiPlayer.xaml.cs:
public void KickStart()
        {
            playListBox.SelectedIndex = 0;
            PlaylistEntry playlistEntry = (PlaylistEntry)playListBox.SelectedItem;
            SetCurrentEntry(playlistEntry);
        }
do following change to method:
void mediaElement_MediaOpened(object sender, EventArgs e)
        {
                mediaElement.Play();
         }

In the App.xaml.cs:
 create a member:
   private bool autoStart = false;

  private void Application_Startup(object sender, StartupEventArgs e) {
   ....
 bool autoPlay = bool.Parse(GetInitParam(e.InitParams, "AutoPlay", "False"));
 autoStart = autoPlay;
 ....
 }

private void CreatePlayer(Playlist playlist)
        {
            if (playlist.Count > 1)
            {
                MultiPlayer player = new MultiPlayer();
                player.Playlist = playlist;
                this.RootVisual = player;
                //add following line
                if (autoStart)
                {
                    player.KickStart(); 
                }
            }
            else
            {
                SimplePlayer simplePlayer = new SimplePlayer();
                foreach (PlaylistEntry entry in playlist)
                {
                    simplePlayer.PlaylistEntry = entry;
                    break;
                }
                this.RootVisual = simplePlayer;
            }
        }

then if you want autostart:

<param name="initParams" value="Playlist=../Playlist.xml,AutoPlay=True" />
 
not autostart:
<param name="initParams" value="Playlist=../Playlist.xml,AutoPlay=False" />

Hopefully this can be helpful to somebody:)
Jul 30, 2010 at 2:17 AM

ops, forget this, you need this method change in MultiPlayer.xaml.cs:

 void mediaElement_MediaEnded(object sender, RoutedEventArgs e)
        {
            // apparently does not go into stop state by itself
            //mediaElement.Stop();
            if (playListBox.SelectedIndex < playListBox.Items.Count - 1)
                playListBox.SelectedIndex++;
            else
                playListBox.SelectedIndex = 0;

        }
Coordinator
Jul 31, 2010 at 9:37 AM

thanks for sharing this