示例#1
0
        private void Client_GeneralCommand(object sender, MediaBrowser.Model.Events.GenericEventArgs <GeneralCommandEventArgs> e)
        {
            try
            {
                var eventArgs = e.Argument;
                log.InfoFormat("Received GeneralCommand: {0}", eventArgs.KnownCommandType);
                switch (eventArgs.KnownCommandType)
                {
                case GeneralCommandType.VolumeUp:
                    if (!player.VolumeUp())
                    {
                        log.Error("Player VolumeUp command failed.");
                    }
                    break;

                case GeneralCommandType.VolumeDown:
                    if (!player.VolumeDown())
                    {
                        log.Error("Player VolumeDown command failed.");
                    }
                    break;

                case GeneralCommandType.ToggleMute:
                    if (!player.ToggleMute())
                    {
                        log.Error("Player ToggleMute command failed.");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                log.Error("General command failed.", ex);
            }
        }
示例#2
0
        private void Client_PlaystateCommand(object sender, MediaBrowser.Model.Events.GenericEventArgs <PlaystateRequest> e)
        {
            try
            {
                var stateReq = e.Argument;
                log.InfoFormat("Received Playstate command: {0}", stateReq.Command);
                switch (stateReq.Command)
                {
                case PlaystateCommand.Pause:
                    if (!player.Pause())
                    {
                        log.Error("Player Pause command failed.");
                    }
                    break;

                case PlaystateCommand.Unpause:
                    if (!player.Unpause())
                    {
                        log.Error("Player Unpause command failed.");
                    }
                    break;

                case PlaystateCommand.Seek:
                    if (stateReq.SeekPositionTicks != null)
                    {
                        if (!player.Seek((long)stateReq.SeekPositionTicks))
                        {
                            log.Error("Player Seek command failed.");
                        }
                    }
                    break;

                case PlaystateCommand.Stop:
                    if (!player.Stop())
                    {
                        log.Error("Player Stop command failed.");
                    }
                    break;

                case PlaystateCommand.PlayPause:
                    if (!player.PlayPause())
                    {
                        log.Error("Player PlayPause command failed.");
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                log.Error("Playstate command failed.", ex);
            }
        }
示例#3
0
 private void Client_SetVolumeCommand(object sender, MediaBrowser.Model.Events.GenericEventArgs <int> e)
 {
     try
     {
         log.InfoFormat("Received SetVolume command: {0}", e.Argument);
         if (!player.SetVolume(e.Argument))
         {
             log.Error("Setting player volume failed.");
         }
     }
     catch (Exception ex)
     {
         log.Error("Setting player volume failed.", ex);
     }
 }
示例#4
0
        private async void Client_PlayCommand(object sender, MediaBrowser.Model.Events.GenericEventArgs <PlayRequest> e)
        {
            try
            {
                log.Debug("Play command received.");
                if (playingItem != null)
                {
                    log.InfoFormat("{0} is already playing, stopping player.", playingItem.Name);
                    StopPlayer();
                }

                var playReq   = e.Argument;
                var playingId = playReq.ItemIds[0]; //only playing 1 item is currently supported
                playingItem = await client.GetItemAsync(playingId, playReq.ControllingUserId);

                log.InfoFormat("Playing \"{0}\" from \"{1}\"", playingItem.Name, playingItem.Path);
                if (player.Play(playingItem.Path, playingItem.UserData.PlaybackPositionTicks))
                {
                    log.Debug("Playback started.");
                    client.ReportPlaybackStartAsync(new PlaybackStartInfo
                    {
                        CanSeek    = true,
                        ItemId     = playingId,
                        PlayMethod = PlayMethod.DirectPlay
                    }).GetAwaiter().GetResult();

                    progressReporter = new ProgressReporter(client, player, 1000, playingId);
                    progressReporter.PlayerStopped += ProgressReporter_PlayerStopped;
                    progressReporter.Start();
                    log.Debug("ProgressReporter started.");
                }
                else
                {
                    log.Error("Player failed to start.");
                }
            }
            catch (Exception ex)
            {
                log.Error("Play command failed.", ex);
            }
        }
示例#5
0
 private void _liveTvManager_TimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs <TimerEventInfo> e)
 {
     SendMessage("TimerCancelled", e.Argument);
 }
 private void OnLiveTvManagerSeriesTimerCreated(object sender, MediaBrowser.Model.Events.GenericEventArgs <TimerEventInfo> e)
 {
     SendMessage("SeriesTimerCreated", e.Argument);
 }
示例#7
0
 private async void OnLiveTvManagerTimerCancelled(object sender, MediaBrowser.Model.Events.GenericEventArgs <TimerEventInfo> e)
 {
     await SendMessage("TimerCancelled", e.Argument).ConfigureAwait(false);
 }
示例#8
0
 private void OnClientRemoteLoggedOut(object sender, MediaBrowser.Model.Events.GenericEventArgs <ApiClient.Model.RemoteLogoutReason> e)
 {
     App.Current.MainPage = new Views.Login();
 }