/** * 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); }