예제 #1
0
        private void bTogglePlay_Click(object sender, EventArgs e)
        {
            if (mediaplayer != null)
            {
                if (mediaplayer.IsStopped || mediaplayer.IsPausing)
                {
                    if (mediaplayer.IsStopped)
                    {
                        // Select MediaItem and start playing
                        if (lbPlaylist.SelectedIndex < 0 && lbPlaylist.Items.Count > 0)
                        {
                            lbPlaylist.SelectedIndex = 0;
                        }
                        if (lbPlaylist.SelectedIndex >= 0)
                        {
                            mediaplayer.ChangeCurrentMediaItemIndex(lbPlaylist.SelectedIndex, false);
                        }
                    }

                    mediaplayer.Play();
                    bTogglePlay.Text = "Pause";
                }
                else if (mediaplayer.IsPlaying)
                {
                    mediaplayer.Pause();
                    bTogglePlay.Text = "Play";
                }
            }
        }