Beispiel #1
0
 /**
  * Runs a liquidsoap command
  * @method liquidsoapcommand
  * @param type the type of the script to start
  * @param command the command to run
  * @param options extra options to provide with the command
  */
 public function liquidsoapcommand($params)
 {
     $liquidsoapManager = new LiquidsoapManager();
     if (!App::user()->hasAccess('shoutzor: manage shoutzor controls')) {
         return $this->formatOutput(__('You have no permission to manage shoutzor controls'), self::METHOD_NOT_AVAILABLE);
     }
     switch ($params['command']) {
         case "start":
             //Get the status of the script before we start it
             $status = $liquidsoapManager->isUp($params['type']);
             //Start our script
             $result = $liquidsoapManager->startScript($params['type']);
             //Make sure we don't import the queue if the script was already running
             if ($params['type'] == 'shoutzor' && $status === false) {
                 $autoDJ = new AutoDJ();
                 $autoDJ->importQueue();
             }
             break;
         case "stop":
             $result = $liquidsoapManager->stopScript($params['type']);
             break;
         case "volume":
             $result = $liquidsoapManager->setVolume($params['type'], $params['options']);
             break;
         case "next":
             $result = $liquidsoapManager->nextTrack();
             break;
         case "remaining":
             $result = $liquidsoapManager->remaining();
             break;
         case "uptime":
             $result = $liquidsoapManager->isUp($params['type']);
             break;
         case "help":
             $result = $liquidsoapManager->help($params['type']);
             break;
         default:
             return $this->formatOutput(__('Invalid command provided'), self::INVALID_PARAMETER_VALUE);
             break;
     }
     if ($result) {
         return $this->formatOutput($result);
     }
     return $this->formatOutput(false, self::ERROR_IN_REQUEST);
 }