Пример #1
0
 /**
  * Get next item if possible
  *
  * @access public
  *
  * @param str $itemId
  */
 public function next()
 {
     Logger::debug(__METHOD__, self::$logfile);
     if ($this->currentPlaying == null) {
         Logger::debug('Playlist is stopped - ignore next();', self::$logfile);
         return;
     }
     $found = false;
     $next = null;
     foreach ($this->items as $id => $item) {
         if ($found) {
             $next = $id;
             break;
         }
         if ($id == $this->currentPlaying) {
             $found = true;
         }
     }
     if (!$found && count($this->items) > 0) {
         $tmp = $this->items;
         $item = array_shift($tmp);
         $next = $item['id'];
     }
     if (!is_null($next)) {
         $this->currentPlaying = $next;
         Logger::debug('Found next: ' . print_r($item, true), self::$logfile);
         $handler = new AjaxHandler();
         $handler->startPlayFromPlaylist($this->deviceId, array('id' => $next));
         $this->setPlaying($next);
     } else {
         Logger::debug('No next item found', self::$logfile);
         $this->stop();
     }
     $this->save();
     return !is_null($next);
 }
Пример #2
0
/**
 * pUPnP, an PHP UPnP MediaControl
 * 
 * Copyright (C) 2012 Mario Klug
 * 
 * This file is part of pUPnP.
 * 
 * pUPnP is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 2 of the
 * License, or (at your option) any later version.
 * 
 * pUPnP 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 pUPnP. If not, see <http://www.gnu.org/licenses/>.
 */
error_reporting(E_ALL);
ini_set('display_errors', 0);
use at\mkweb\upnp\backend\AjaxHandler;
use at\mkweb\upnp\exception\UPnPException;
require_once 'src/at/mkweb/upnp/init.php';
$action = $_GET['action'];
unset($_GET['action']);
try {
    $handler = new AjaxHandler();
    $handler->call($action, $_GET);
} catch (UPnPException $e) {
    $handler = new AjaxHandler();
    $handler->respond(array('error' => $e->getMessage()));
}