Example #1
0
 private void OnEpisodeButtonClicked(object sender, EventArgs e)
 {
     int episode = int.Parse(((Button)sender).Text);
     if (player == null || player.IsDisposed)
     {
         player = new FormJwPlayer();
         player.Open(currentProvider);
         player.EpisodeChange += Player_EpisodeChange;
     }
     
     player.Play(selectedSeason, episode);
 }
Example #2
0
        private void TcpServer_NetworkControl(TcpServer source, NetworkControlEventArgs e)
        {
            switch (e.EventId)  //happens always
            {
                case NetworkControlEvent.SkipStart:
                    int newSkipStartValue = e.Data.ReadInt(0);
                    numericUpDownSkipStart.Value = newSkipStartValue;
                    break;
                case NetworkControlEvent.SkipEnd:
                    int newSkipEndValue = e.Data.ReadInt(0);
                    numericUpDownSkipEnd.Value = newSkipEndValue;
                    break;
            }

            if (player != null && !player.IsDisposed && player.IsLoaded)    //player available
            {
                switch (e.EventId)
                {
                    case NetworkControlEvent.PlayPause:
                        Task.Run(async () =>
                        {
                            if (await player.GetIsPlayingAsync())
                            {
                                player.Pause();
                            }
                            else
                            {
                                player.Play();
                            }
                        });
                        break;
                    case NetworkControlEvent.Next:
                        player.Next();
                        break;
                    case NetworkControlEvent.Previous:
                        player.Previous();
                        break;
                    case NetworkControlEvent.PlayEpisode:
                        player.Play(selectedSeason, e.Data.ReadInt(0));
                        break;
                    case NetworkControlEvent.ClosePlayer:
                        player.Close();
                        break;
                    case NetworkControlEvent.SeekTo:
                        int pos = e.Data.ReadInt(0);
                        player.SetPosition(pos);
                        break;
                    case NetworkControlEvent.ToggleFullscreen:
                        player.Maximized = !player.Maximized;
                        break;
                    case NetworkControlEvent.Volume:
                        player.SetVolume(e.Data[0]);
                        break;
                }
            }
            else    //player not available
            {
                switch (e.EventId)
                {
                    case NetworkControlEvent.Volume:
                        Settings.WriteValue(Settings.VOLUME, e.Data[0]);
                        break;
                    case NetworkControlEvent.PlayEpisode:
                        player = new FormJwPlayer();
                        player.Open(currentProvider);
                        player.EpisodeChange += Player_EpisodeChange;
                        player.Play(selectedSeason, e.Data.ReadInt(0));
                        break;
                }
            }
            
        }