示例#1
0
 /**
  * @Route("/", name="index")
  */
 public function indexAction()
 {
     $config = App::module('shoutzor')->config('liquidsoap');
     $liquidsoapManager = new LiquidsoapManager();
     $wrapperActive = $liquidsoapManager->isUp('wrapper');
     $shoutzorActive = $liquidsoapManager->isUp('shoutzor');
     $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal');
     $form->addField(new InputField("skipTrack", "skipTrack", "Skip Track", "button", "Skip Track", "Sends the "skip track" command", "uk-button uk-button-primary"));
     $content = $form->render();
     return ['$view' => ['title' => __('Shoutzor Controls'), 'name' => 'shoutzor:views/admin/controls.php'], 'form' => $content];
 }
示例#2
0
 public function addToQueue(Media $media, $createRequest = true)
 {
     //Get the config options
     $config = App::module('shoutzor')->config('shoutzor');
     //Get the path to the file
     $filepath = $config['mediaDir'] . '/' . $media->filename;
     //Make sure the file is readable
     if (!is_readable($filepath)) {
         throw new Exception(__('Cannot read music file ' . $filepath . ', Permission denied.'));
     }
     //Add request to the playlist
     $liquidsoapManager = new LiquidsoapManager();
     $liquidsoapManager->queueTrack($filepath);
     if ($createRequest === true) {
         //Save request in the database
         $request = Request::create();
         $request->save(array('media_id' => $media->id, 'requester_id' => App::user()->id, 'requesttime' => (new \DateTime())->format('Y-m-d H:i:s')));
     }
     return true;
 }
示例#3
0
 /**
  * @Route("/", name="index")
  */
 public function indexAction()
 {
     $config = App::module('shoutzor')->config('liquidsoap');
     $liquidsoapManager = new LiquidsoapManager();
     $wrapperActive = $liquidsoapManager->isUp('wrapper');
     $shoutzorActive = $liquidsoapManager->isUp('shoutzor');
     $form = new FormGenerator('', 'POST', 'uk-form uk-form-horizontal');
     $form->addField(new DivField("Permission Check", $config['logDirectoryPath'] . (is_writable($config['logDirectoryPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['logDirectoryPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger"));
     //Usually the log directory and the socket directory will be the same
     //Thus, showing twice that the same directory is (not) writable has no use
     if ($config['logDirectoryPath'] != $config['socketPath']) {
         $form->addField(new DivField("Permission Check", $config['socketPath'] . (is_writable($config['socketPath']) ? " is writable" : " is not writable! chown manually to www-data:www-data"), "", is_writable($config['socketPath']) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger"));
     }
     $form->addField(new DivField("Permission Check", $liquidsoapManager->getPidFileDirectory() . (is_writable($liquidsoapManager->getPidFileDirectory()) ? " is writable" : " is not writable! chown manually to liquidsoap:www-data"), "", is_writable($liquidsoapManager->getPidFileDirectory()) ? "uk-alert uk-alert-success" : "uk-alert uk-alert-danger"));
     $form->addField(new DividerField());
     $form->addField(new InputField("wrapperToggle", "wrapperToggle", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "button", $wrapperActive ? "Deactivate Wrapper" : "Activate Wrapper", "(De)activates the wrapper liquidsoap script", $wrapperActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY));
     if ($wrapperActive === false) {
         $form->setError("The wrapper script is not activated!");
     } else {
         $form->setSuccess("The wrapper script is up and running!");
     }
     $form->addField(new InputField("shoutzorToggle", "shoutzorToggle", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "button", $shoutzorActive ? "Deactivate Shoutzor" : "Activate Shoutzor", "(De)activates the shoutzor liquidsoap script", $shoutzorActive ? "uk-button uk-button-danger" : "uk-button uk-button-primary", 'data-status="' . ($wrapperActive ? 'started' : 'stopped') . '"'))->setValidationType(FormValidation::TYPE_STRING)->setValidationRequirements(array(FormValidation::REQ_NOTEMPTY));
     if ($shoutzorActive === false) {
         if ($wrapperActive === false) {
             $form->setError("The wrapper script needs to be activated first!");
         } else {
             $form->setError("The shoutzor script is not activated!");
         }
     } else {
         $form->setSuccess("The shoutzor script is up and running!");
     }
     $content = $form->render();
     return ['$view' => ['title' => __('Shoutzor System'), 'name' => 'shoutzor:views/admin/system.php'], 'form' => $content];
 }
示例#4
0
 /**
  * Automatically fixes the shoutzor script
  * This method gets called by shoutzor when blank audio is detected for a prolonged time
  * As the result of some kind of crash (possibly?)
  * @method autofix
  */
 public function autofix($params)
 {
     if ($this->ensureLocalhost() === false) {
         return $this->formatOutput(__('You have no access to this method'), self::METHOD_NOT_AVAILABLE);
     }
     //Prevent the request method from adding the request while we are restarting shoutzor
     $this->shoutzorRunning = false;
     $liquidsoapManager = new LiquidsoapManager();
     $liquidsoapManager->stopScript('shoutzor');
     sleep(5);
     $liquidsoapManager->startScript('shoutzor');
     sleep(1);
     //Get the remaining queue and add them all to shoutzor
     $autoDJ = new AutoDJ();
     $autoDJ->importQueue();
     //Shoutzor is back up and running, requests are now allowed again
     $this->shoutzorRunning = true;
     return $this->formatOutput(true);
 }