예제 #1
0
 /**
  * jukeboxControl
  * Control the jukebox.
  * Takes the action with optional index, offset, song id and volume gain in parameters.
  * Not supported.
  */
 public static function jukeboxcontrol($input)
 {
     self::check_version($input, "1.2.0");
     $action = self::check_parameter($input, 'action');
     $id = $input['id'];
     $gain = $input['gain'];
     $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
     debug_event('subsonic', 'Using Localplay controller: ' . AmpConfig::get('localplay_controller'), 5);
     $localplay = new Localplay(AmpConfig::get('localplay_controller'));
     if ($localplay->connect()) {
         $ret = false;
         switch ($action) {
             case 'get':
             case 'status':
                 $ret = true;
                 break;
             case 'start':
                 $ret = $localplay->play();
                 break;
             case 'stop':
                 $ret = $localplay->stop();
                 break;
             case 'skip':
                 if (isset($input['index'])) {
                     if ($localplay->skip($input['index'])) {
                         $ret = $localplay->play();
                     }
                 } elseif (isset($input['offset'])) {
                     debug_event('subsonic', 'Skip with offset is not supported on JukeboxControl.', 5);
                 } else {
                     $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
                 }
                 break;
             case 'set':
                 $localplay->delete_all();
             case 'add':
                 if ($id) {
                     if (!is_array($id)) {
                         $rid = array();
                         $rid[] = $id;
                         $id = $rid;
                     }
                     foreach ($id as $i) {
                         $url = null;
                         if (Subsonic_XML_Data::isSong($i)) {
                             $url = Song::generic_play_url('song', Subsonic_XML_Data::getAmpacheId($i), '', 'api');
                         } elseif (Subsonic_XML_Data::isVideo($i)) {
                             $url = Song::generic_play_url('video', Subsonic_XML_Data::getAmpacheId($i), '', 'api');
                         }
                         if ($url) {
                             debug_event('subsonic', 'Adding ' . $url, 5);
                             $stream = array();
                             $stream['url'] = $url;
                             $ret = $localplay->add_url(new Stream_URL($stream));
                         }
                     }
                 }
                 break;
             case 'clear':
                 $ret = $localplay->delete_all();
                 break;
             case 'remove':
                 if (isset($input['index'])) {
                     $ret = $localplay->delete_track($input['index']);
                 } else {
                     $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_MISSINGPARAM);
                 }
                 break;
             case 'shuffle':
                 $ret = $localplay->random(true);
                 break;
             case 'setGain':
                 $ret = $localplay->volume_set($gain * 100);
                 break;
         }
         if ($ret) {
             $r = Subsonic_XML_Data::createSuccessResponse();
             if ($action == 'get') {
                 Subsonic_XML_Data::addJukeboxPlaylist($r, $localplay);
             } else {
                 Subsonic_XML_Data::createJukeboxStatus($r, $localplay);
             }
         }
     }
     self::apiOutput($input, $r);
 }
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License v2
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
$localplay = new Localplay(AmpConfig::get('localplay_controller'));
$localplay->connect();
$status = $localplay->status();
if ($browse->get_show_header()) {
    require AmpConfig::get('prefix') . '/templates/list_header.inc.php';
}
?>
<table class="tabledata" cellpadding="0" cellspacing="0">
    <thead>
        <tr class="th-top">
            <th class="cel_track"><?php 
echo T_('Track');
?>
</th>
            <th class="cel_name"><?php 
echo T_('Name');
?>
예제 #3
0
 /**
  * create_localplay
  * This calls the Localplay API to add the URLs and then start playback
  */
 public function create_localplay()
 {
     $localplay = new Localplay(AmpConfig::get('localplay_controller'));
     $localplay->connect();
     $append = $_REQUEST['append'];
     if (!$append) {
         $localplay->delete_all();
     }
     foreach ($this->urls as $url) {
         $localplay->add_url($url);
     }
     if (!$append) {
         $localplay->play();
     }
 }
예제 #4
0
 /**
  * localplay
  * This is for controling localplay
  */
 public static function localplay($input)
 {
     // Load their localplay instance
     $localplay = new Localplay(AmpConfig::get('localplay_controller'));
     $localplay->connect();
     switch ($input['command']) {
         case 'next':
         case 'prev':
         case 'play':
         case 'stop':
             $result_status = $localplay->{$input}['command']();
             $xml_array = array('localplay' => array('command' => array($input['command'] => make_bool($result_status))));
             echo XML_Data::keyed_array($xml_array);
             break;
         default:
             // They are doing it wrong
             echo XML_Data::error('405', T_('Invalid Request'));
             break;
     }
     // end switch on command
 }
예제 #5
0
 /**
  * create_localplay
  * This calls the Localplay API to add the URLs and then start playback
  */
 public function create_localplay()
 {
     $localplay = new Localplay(AmpConfig::get('localplay_controller'));
     $localplay->connect();
     $append = $_REQUEST['append'];
     if (!$append) {
         $localplay->delete_all();
     }
     foreach ($this->urls as $url) {
         $localplay->add_url($url);
     }
     if (!$append) {
         // We don't have metadata on Stream_URL to know its kind
         // so we check the content to know if it is democratic
         if (count($this->urls) == 1) {
             $furl = $this->urls[0];
             if (strpos($furl->url, "&demo_id=1") !== false && $furl->time == -1) {
                 // If democratic, repeat the song to get the next voted one.
                 debug_event('stream_playlist', 'Playing democratic on localplay, enabling repeat...', 5);
                 $localplay->repeat(true);
             }
         }
         $localplay->play();
     }
 }