-{"player":"sudo omxplayer -s -o alsa:plughw:0,1 -y --threshold %Buffer% --no-osd --layer 100 --timeout 3 --aspect-mode stretch '%URL%'","background":"\/var\/www\/html\/yawep\/pictures/originalcolorbars480.png","name":"Player #new","volume":"100","buffer":"0.70","url":"udp:\/\/@1.2.3.4:12345","is_bg":0,"is_boot":0}
+{"player":"sudo omxplayer -s -o alsa:plughw:0,1 -y --threshold %Buffer% --no-osd --layer 100 --timeout 3 --aspect-mode stretch '%URL%'","background":"\/var\/www\/html\/yawep\/pictures/originalcolorbars480.png","name":"Player #new","volume":"100","buffer":"0.70","url":"udp:\/\/@1.2.3.4:12345","is_bg":0,"is_boot":0,"restart":"03:00"}
$config = read_json_config($config_file, 'config_default.json');
$screenrc_file = "/tmp/yawep_player_screenrc";
$screenlog_file = "/tmp/yawep_screen.log";
-$cron_file = "/etc/cron.d/yawep_player";
+$cron_boot_file = "/etc/cron.d/yawep_boot";
+$cron_restart_file = "/etc/cron.d/yawep_player_restart";
$is_bg_checked_html = '';
if ( isset($config['is_bg']) && $config['is_bg'] ) {
exec("screen -X -S yawep_screen_player quit");
}
+ if ( isset($_GET['restart']) ) {
+ $h_m = explode(':', $_GET['restart']);
+ if ( $_GET['restart'] != '' && isset($h_m[0]) && isset($h_m[1]) ) {
+ $h = sprintf("%02d", $h_m[0]);
+ $m = sprintf("%02d", $h_m[1]);
+ if ( $h < 0 or $h > 23 or $m < 0 or $m > 59 ) {
+ $config['restart'] = '';
+ exec("sudo sh -c 'rm $cron_restart_file'");
+ } else {
+ $config['restart'] = "$h:$m";
+ exec("sudo sh -c 'cp /var/www/html/yawep/crontab_player_restart $cron_restart_file'");
+ exec("sudo sed -i 's/__MINUTE__/$m/;s/__HOUR__/$h/' $cron_restart_file");
+ }
+ } else {
+ $config['restart'] = '';
+ exec("sudo sh -c 'rm $cron_restart_file'");
+ }
+ $r = array();
+ $r['restart'] = $config['restart'];
+ print json_encode($r);
+ }
if ( isset($_GET['reboot']) ) {
exec("sudo reboot");
if ( isset($_GET['bootonoff']) ) {
if ( $_GET['bootonoff'] == 'true' ) {
$config['is_boot'] = 1;
- exec("sudo sh -c 'cp /var/www/html/yawep/crontab_reboot $cron_file'");
+ exec("sudo sh -c 'cp /var/www/html/yawep/crontab_reboot $cron_boot_file'");
} else {
$config['is_boot'] = 0;
- exec("sudo sh -c 'rm $cron_file'");
+ exec("sudo sh -c 'rm $cron_boot_file'");
}
}
if ( isset($_GET['status']) ) {
print "<tr>";
print "<td><label>Player</label></td><td class=\"col-md-2\"><input type=\"text\" class=\"form-control\" name=\"player\" value=\"" . $config['player']. "\"></input></td>";
print "</tr>";
+ print "<tr>";
+ print "<td><label>Restart</label></td><td class=\"col-md-2\"><input type=\"text\" class=\"form-control\" name=\"restart\" value=\"" . $config['restart']. "\"></input></td>";
+ print "</tr>";
print "</table>";
print "<hr/>";
print "<button type=\"button\" class=\"btn btn-success\" name=\"start\">Start</button>";