private static function process() { if (PlaylistService::checkScreen()) { $playlist = PlaylistService::getPlaylist(); if (!($screen = PlaylistService::getScreen())) { System_Daemon::notice('playlist %s ended', $playlist['name']); self::killScreen(PlaylistService::getPrevScreenOwnId()); PlaylistService::disablePlaylist($playlist['id']); PlaylistService::savePlaylist(); return true; } System_Daemon::notice('screen has been changed to %s/%d (%d assets)', $playlist['name'], PlaylistService::getScreenId(), count($screen['assets'])); // TODO: foreach instead of [0] switch ($screen['assets'][0]['type']) { case 'clock': $pid = intval(shell_exec('xclock > /dev/null 2>&1 & echo $!')); break; case 'video': if (strpos($screen['assets'][0]['filename'], '/') === false) { $filename = sprintf('%s./data/assets/video/%s', __DIR__ . '/../../', $screen['assets'][0]['filename']); } else { $filename = $screen['assets'][0]['filename']; } if (file_exists('/usr/bin/omxplayer')) { $command = 'timeout %s omxplayer %s > /dev/null 2>&1 & echo $!'; $type = 'kill'; } elseif (file_exists('/usr/bin/mplayer')) { $command = 'timeout %s mplayer -fs %s > /dev/null 2>&1 & echo $!'; $type = 'kill'; } else { continue; } $command = sprintf($command, round($screen['duration'] / 1000) + 3, escapeshellarg($filename)); System_Daemon::notice($command); $pid = intval(shell_exec($command)); break; case 'image': if (strpos($screen['assets'][0]['filename'], '/') === false) { $filename = sprintf('%s./data/assets/image/%s', __DIR__ . '/../../', $screen['assets'][0]['filename']); } else { $filename = $screen['assets'][0]['filename']; } $command = sprintf('timeout %s feh --auto-zoom --borderless --fullscreen %s > /dev/null 2>&1 & echo $!', round($screen['duration'] / 1000) + 2, escapeshellarg($filename)); System_Daemon::debug($command); $pid = intval(shell_exec($command)); $type = 'kill'; break; default: System_Daemon::warning('{appName} received unrecognized task: %s', $s); break; } if (isset($pid)) { self::$pids[PlaylistService::getScreenOwnId()] = array('type' => $type, 'pid' => $pid); System_Daemon::info('new process with PID %s has been started', $pid); } } return true; }