private static void RunExtendedCommand(BasicCommand cmd) { try { switch (cmd.CommandType) { case CommandType.BrowseRemoteFiles: (cmd as BrowseRemoteFilesCommand).Execute(); break; case CommandType.GetDriveList: (cmd as GetDriveListCommand).Execute(); break; case CommandType.QueryMediaRenderer: (cmd as QueryMediaRendererCommand).Execute(); break; } throw new ArgumentException("Uncomprehensible command", "cmd"); } catch (Exception exception) { Logger.LogException(exception); } }
public void EnqueueCommand(BasicCommand cmd) { if (cmd != null) { commandQueue.Enqueue(cmd); } }
public static void SendPlayerCommand(BasicCommand command, bool useIpc = false) { ThreadPool.QueueUserWorkItem(c => { int i = 0; bool playerWasAlreadyRunning = IsPlayerRunning(); if (!useIpc) { // See if player is started; if not - start it while ((!IsPlayerRunning() && i < MaxStartupAttempts)) { Process.Start(ProTONEConfig.PlayerInstallationPath); i++; Thread.Sleep(1000); } } if (IsPlayerRunning()) { if (!playerWasAlreadyRunning) { Thread.Sleep(400); } //// If we came to this poin the player is running. //// Send the command (it should arrive to player). if (useIpc) { IPCRemoteControlProxy.PostRequest(ProTONEConstants.PlayerName, command.ToString()); } else { WmCopyDataSender.SendData(ProTONEConstants.PlayerName, command.ToString()); } } else { if (useIpc) { Logger.LogError("Could not send command because the player is not running."); } else { Logger.LogError("Could not send command because the player could not be launched from path: {0}", ProTONEConfig.PlayerInstallationPath); } } } ); }
public void RunCommand(BasicCommand cmd) { if (cmd == null) return; if (cmd.RequiresAnswer) { RunExtendedCommand(cmd); } if (_target != null) { _target.EnqueueCommand(cmd); } }
public void RunCommand(BasicCommand cmd) { if (cmd == null) { return; } if (cmd.RequiresAnswer) { RunExtendedCommand(cmd); } if (_target != null) { _target.EnqueueCommand(cmd); } }
void _wcdReceiver_DataReceived(string data) { BasicCommand cmd = BasicCommand.Create(data); EventDispatch.DispatchEvent(BasicCommand.EventName, cmd); }
private void ProcessCommand(BasicCommand cmd) { switch (cmd.CommandType) { case CommandType.Activate: RevealWindow(); mediaPlayer.DoLayout(); break; case CommandType.Terminate: if (CanTerminate()) { Application.Exit(); } break; case CommandType.PlayFiles: mediaPlayer.PlayFiles(cmd.Args); break; case CommandType.EnqueueFiles: mediaPlayer.EnqueueFiles(cmd.Args); break; case CommandType.Playback: ProcessPlaybackCommand(cmd.Args); break; case CommandType.ClearPlaylist: mediaPlayer.ClearPlaylist(); break; case CommandType.KeyPress: (cmd as KeyPressCommand).Execute(); break; } }