function sonos3_update() { $cron = cron::byClassAndFunction('sonos3', 'pull'); if (!is_object($cron)) { $cron = new cron(); } $cron->setClass('sonos3'); $cron->setFunction('pull'); $cron->setEnable(1); $cron->setDeamon(1); $cron->setDeamonSleepTime(5); $cron->setTimeout(1440); $cron->setSchedule('* * * * *'); $cron->save(); $cron->stop(); foreach (sonos3::byType('sonos3') as $sonos) { $sonos->save(); } $files = array('24 LED Bright.ttf', '24 LED Grid.ttf', '24 LED Modul.ttf', '24 LED.ttf', 'advanced_dot_digital-7.ttf', 'AHDN.ttf', 'alpha04.ttf', 'CUBS LED TFB.ttf', 'enhanced_led_board-7.ttf', 'led_counter-7.ttf', 'liquid_crystal_display.ttf', 'liquid.ttf'); foreach ($files as $file) { $path = dirname(__FILE__) . '/../core/template/fonts/' . $file; if (file_exists($path)) { unlink($path); } } }
public function execute($_options = array()) { if ($this->getType() == 'info') { return; } try { $eqLogic = $this->getEqLogic(); $sonos = sonos3::getSonos(); $controller = sonos3::getControllerByIp($eqLogic->getLogicalId()); if ($this->getLogicalId() == 'play') { if ($eqLogic->getConfiguration('model') == 'PLAYBAR') { $state = $eqLogic->getCmd(null, 'state'); $track_title = $eqLogic->getCmd(null, 'track_title'); if (is_object($state) && is_object($track_title)) { if ($track_title->execCmd(null, 2) == __('Aucun', __FILE__) && $state->execCmd(null, 2) == __('Lecture', __FILE__)) { return $controller->unmute(); } } } $controller->play(); } if ($this->getLogicalId() == 'stop') { if ($eqLogic->getConfiguration('model') == 'PLAYBAR') { $state = $eqLogic->getCmd(null, 'state'); $track_title = $eqLogic->getCmd(null, 'track_title'); if (is_object($state) && is_object($track_title)) { if ($track_title->execCmd(null, 2) == __('Aucun', __FILE__) && $state->execCmd(null, 2) == __('Lecture', __FILE__)) { return $controller->mute(); } } } $controller->pause(); } if ($this->getLogicalId() == 'pause') { if ($eqLogic->getConfiguration('model') == 'PLAYBAR') { $state = $eqLogic->getCmd(null, 'state'); $track_title = $eqLogic->getCmd(null, 'track_title'); if (is_object($state) && is_object($track_title)) { if ($cmd_track_title->execCmd(null, 2) == __('Aucun', __FILE__) && $state->execCmd(null, 2) == __('Lecture', __FILE__)) { return $controller->mute(); } } } $controller->pause(); } if ($this->getLogicalId() == 'previous') { $controller->previous(); } if ($this->getLogicalId() == 'next') { $controller->next(); } if ($this->getLogicalId() == 'mute') { $controller->mute(); } if ($this->getLogicalId() == 'unmute') { $controller->unmute(); } if ($this->getLogicalId() == 'repeat') { $controller->setRepeat(!$controller->getRepeat()); } if ($this->getLogicalId() == 'shuffle') { $controller->setShuffle(!$controller->getShuffle()); } if ($this->getLogicalId() == 'setVolume') { if ($_options['slider'] < 0) { $_options['slider'] = 0; } if ($_options['slider'] > 100) { $_options['slider'] = 100; } $controller->setVolume($_options['slider']); } if ($this->getLogicalId() == 'play_playlist') { if (!$controller->isUsingQueue()) { $controller->useQueue(); } $queue = $controller->getQueue(); $playlist = $sonos->getPlaylistByName(trim(trim($_options['title']), '"')); if ($playlist == null) { foreach ($sonos->getPlaylists() as $playlist_search) { if (str_replace(' ', ' ', $playlist_search->getName()) == $_options['title']) { $playlist = $playlist_search; break; } } } if ($playlist == null) { throw new Exception(__('Playlist non trouvé : ', __FILE__) . trim($_options['title'])); } $tracks = $playlist->getTracks(); $queue->clear(); if (count($tracks) > 1) { if (isset($_options['message']) && $_options['message'] == 'random') { shuffle($tracks); } $queue->addTrack($tracks[0]); $controller->play(); unset($tracks[0]); $queue->addTracks($tracks); } else { $queue->addTracks($tracks); $controller->play(); } } if ($this->getLogicalId() == 'play_radio') { $radio = $sonos->getRadio(); $stations = $radio->getFavouriteStations(); if ($stations->getName() == $_options['title']) { $controller->useStream($show)->play(); } } if ($this->getLogicalId() == 'add_speaker') { $speaker = $sonos->getSpeakerByRoom($_options['title']); $controller->addSpeaker($speaker); } if ($this->getLogicalId() == 'remove_speaker') { $speaker = $sonos->getSpeakerByRoom($_options['title']); $controller->removeSpeaker($speaker); } if ($this->getLogicalId() == 'tts') { $path = explode('/', trim(config::byKey('tts_path', 'sonos3'), '/')); $server = new Server(config::byKey('tts_host', 'sonos3'), config::byKey('tts_username', 'sonos3'), config::byKey('tts_password', 'sonos3')); $share = $server->getShare($path[0]); $adapter = new SmbAdapter($share); $filesystem = new Filesystem($adapter); $folder = array_pop($path); $directory = new Directory($filesystem, config::byKey('tts_host', 'sonos3') . '/' . implode('/', $path), $folder); if (config::byKey('ttsProvider', 'sonos3') != 'voxygen' && strlen($_options['message']) > 100) { $_options['message'] = substr($_options['message'], 0, 100); } $track = new TextToSpeech(trim($_options['message']), $directory, new GoogleProvider()); $track->setLanguage("fr"); $track->setProvider(new VoxygenProvider()); $track->getProvider()->setVoice(config::byKey('ttsVoxygenVoice', 'sonos3', 'Helene')); if ($_options['title'] != '' && is_numeric($_options['title'])) { $controller->interrupt($track, $_options['title']); } else { $controller->interrupt($track); } } else { sonos3::pull($eqLogic->getId()); } } catch (Exception $e) { log::add('sonos', 'info', $e->getMessage()); } }
$return['eqLogics'] = array(); if (init('object_id') == '') { foreach (object::all() as $object) { foreach ($object->getEqLogic(true, false, 'sonos3') as $sonos) { $return['eqLogics'][] = $sonos->toHtml(init('version')); } } } else { foreach ($object->getEqLogic(true, false, 'sonos3') as $sonos) { $return['eqLogics'][] = $sonos->toHtml(init('version')); } foreach (object::buildTree($object) as $child) { $sonoss = $child->getEqLogic(true, false, 'sonos3'); if (count($sonoss) > 0) { foreach ($sonoss as $sonos) { $return['eqLogics'][] = $sonos->toHtml(init('version')); } } } } ajax::success($return); } if (init('action') == 'updateSonos') { sonos3::updateSonos(); ajax::success(); } throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action')); /* * *********Catch exeption*************** */ } catch (Exception $e) { ajax::error(displayExeption($e), $e->getCode()); }