Exemplo n.º 1
0
    /// <summary>
    /// Evaluate button press from remote
    /// </summary>
    /// <param name="button">Remote Button</param>
    private void OnRemoteClick(object sender, RemoteEventArgs e)
      //RemoteButton button)
    {
      RemoteButton remoteButton = e.Button;

      // Set LastHidRequest, otherwise the HID handler (if enabled) would react on some remote buttons (double execution of command)
      switch (remoteButton)
      {
        case RemoteButton.Record:
          InputDevices.LastHidRequest = AppCommands.MediaRecord;
          break;
        case RemoteButton.Stop:
          InputDevices.LastHidRequest = AppCommands.MediaStop;
          break;
        case RemoteButton.Pause:
          InputDevices.LastHidRequest = AppCommands.MediaPause;
          break;
        case RemoteButton.Rewind:
          InputDevices.LastHidRequest = AppCommands.MediaRewind;
          break;
        case RemoteButton.Play:
          InputDevices.LastHidRequest = AppCommands.MediaPlay;
          break;
        case RemoteButton.Forward:
          InputDevices.LastHidRequest = AppCommands.MediaFastForward;
          break;
        case RemoteButton.Replay:
          InputDevices.LastHidRequest = AppCommands.MediaPreviousTrack;
          break;
        case RemoteButton.Skip:
          InputDevices.LastHidRequest = AppCommands.MediaNextTrack;
          break;
        case RemoteButton.Back:
          InputDevices.LastHidRequest = AppCommands.BrowserBackward;
          break;
        case RemoteButton.ChannelUp:
          InputDevices.LastHidRequest = AppCommands.MediaChannelUp;
          break;
        case RemoteButton.ChannelDown:
          InputDevices.LastHidRequest = AppCommands.MediaChannelDown;
          break;
        case RemoteButton.Mute:
          InputDevices.LastHidRequest = AppCommands.VolumeMute;
          break;
        case RemoteButton.VolumeUp:
          return; // Don't handle this command, benefit from OS' repeat handling instead
        case RemoteButton.VolumeDown:
          return; // Don't handle this command, benefit from OS' repeat handling instead
      }

      // Get & execute Mapping
      RemoteHandler((int) remoteButton);
    }
Exemplo n.º 2
0
    private static void OnClick(object sender, RemoteEventArgs e)
    {
      if (e.Button != RemoteButton.Start)
        return;

      ILogger logger = ServiceRegistration.Get<ILogger>();
      logger.Info("Received StartButton press");

      Process[] processes = Process.GetProcessesByName("MP2-Client");

      if (processes.Length == 0)
      {
        logger.Info("MP2-Client is not running - starting it.");
        StartClient();
      }
      else if (processes.Length == 1)
      {
        logger.Info("MP2-Client is already running - switching focus.");
        SwitchFocus();
      }
      else
      {
        logger.Info("More than one window named 'MediaPortal' has been found!");
        foreach (Process procName in processes)
        {
          logger.Debug("MPTray: {0} (Started: {1}, ID: {2})", procName.ProcessName,
                       procName.StartTime.ToShortTimeString(), procName.Id);
        }
      }
    }