Beispiel #1
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;
 }