Example #1
0
    static $fifoFile;
    /**
     * The path to the fifo status file
     * Will be set bellow this class
     *
     * @var string
     */
    static $fifoStatusFile;
    /**
     * All hotkeys
     *
     * @var mixed
     */
    static $hotkeys = array("q" => array("key" => "81"), "p" => array("key" => "80"), "-" => array("key" => "189,109"), "+" => array("key" => "187,107"), "left" => array("key" => "37", "shortcut" => ""), "right" => array("key" => "39", "shortcut" => ""), "down" => array("key" => "40", "shortcut" => ""), "up" => array("key" => "38", "shortcut" => ""), "z" => array("key" => "90"), "1" => array("key" => "50,98"), "2" => array("key" => "49,57"), "j" => array("key" => "74"), "k" => array("key" => "75"), "i" => array("key" => "73"), "o" => array("key" => "79"), "n" => array("key" => "78"), "m" => array("key" => "77"), "s" => array("key" => "83"), "d" => array("key" => "68"), "f" => array("key" => "70"));
    /**
     * Send commands to omxplayer
     *
     * @param mixed $omxcmd
     * @param mixed $method
     */
    static function sendCommand($omxcmd, $method)
    {
        $script = __DIR__ . "/../omx-{$method}.sh";
        $cmd = "timeout 5 sh " . escapeshellarg($script) . " " . $omxcmd . " " . escapeshellarg(self::$fifoFile) . " > /dev/null 2>&1";
        $output = $return = "";
        exec($cmd, $output, $return);
    }
}
OMX::$fifoFile = __DIR__ . "/../tmp/fifo";
OMX::$fifoStatusFile = __DIR__ . "/../tmp/fifo.status";
Example #2
0
             $startCmd = escapeshellarg($_POST["path"]) . " " . (isset($options["speedfix"]) && $options["speedfix"] ? "1" : "0");
             switch ($_POST["shortcut"]) {
                 case "start":
                     file_put_contents(OMX::$fifoStatusFile, json_encode(array("path" => $_POST["path"])));
                     OMX::sendCommand($startCmd, "start");
                     break;
                 case "p":
                     if (!file_exists(OMX::$fifoFile)) {
                         OMX::sendCommand($startCmd, "start");
                     } else {
                         OMX::sendCommand("p", "pipe");
                     }
                     break;
                 default:
                     $key = OMX::$hotkeys[$_POST["shortcut"]];
                     OMX::sendCommand(isset($key["shortcut"]) ? $key["shortcut"] : $_POST["shortcut"], "pipe");
             }
             break;
     }
     die;
 }
 ?>
 <!DOCTYPE html>
 <html>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
         <meta name="viewport" content="width=670, initial-scale=0.8">
         <link rel="stylesheet" type="text/css" href="css/site.css">
         <meta http-equiv="X-UA-Compatible" content="IE=edge">
         <script type="text/javascript" src="js/jquery.js"></script>
         <script type="text/javascript">