Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // PHP script to get status of vlc because javascript is shit
- $username = '';
- $password = '1234';
- $server = 'localhost:8080/requests/status.xml';
- $fullscreenurl = 'localhost:8080/requests/status.xml?command=fullscreen';
- $clearplurl = 'localhost:8080/requests/status.xml?command=pl_empty';
- $stopurl = 'localhost:8080/requests/status.xml?command=pl_pause';
- $playurl = 'localhost:8080/requests/status.xml?command=in_play&input=';
- $filelocation = '\\\\NasDrive\\Library\\';
- $context = stream_context_create(array( //needed to authorise VLC
- 'http' => array(
- 'header' => "Authorization: Basic " . base64_encode("$username:$password")
- )
- )
- );
- //Checks status
- $data = file_get_contents("http://$server", false, $context);
- $xml=simplexml_load_string($data);
- if($_POST['action'] == 'checkit') {
- if ($xml === false) {
- echo "Failed loading XML: Check Password and make sure VLC is running ";
- foreach(libxml_get_errors() as $error) {
- echo "<br>", $error->message;
- }
- } else {
- $data = file_get_contents("http://$server", false, $context);
- $xml=simplexml_load_string($data);
- $fullscreenstatus = $xml->fullscreen; //States from the xml
- $vlcstate = $xml->state;
- //$videoplaying = $xml->information->category['filename'];
- $videoloop = $xml->loop;
- echo "<u><b>Status</u>: </b><i>" . $vlcstate . " - Filename.mp4</i><a href='' onclick='checkvlcstatus()'><img src='refresh.png' alt='Toggle Fullscreen'></a> </br> <b><u>Fullscreen</u>:</b><i> ". $fullscreenstatus ."</i> <a href='#' onclick='fullscreen()'><img src='power.png' alt='Toggle Fullscreen'></a> </br> <b><u>Loop</u>:</b><i> ".$videoloop." </i><a href='#' onclick='fullscreen()'><img src='power.png' alt='Toggle Fullscreen'></a></br><b><u>Spreadsheet</u>: </b><a href='http://www.google.com'><img src='go.png' alt='Toggle Fullscreen'></a>";
- }
- }
- // Toggles fullscreen
- if($_POST['action'] == 'fullscreen') {
- if ($xml === false) {
- echo "Failed loading XML: Check Password and make sure VLC is running ";
- foreach(libxml_get_errors() as $error) {
- echo "<br>", $error->message;
- }
- } else {
- $data = file_get_contents("http://$fullscreenurl", false, $context);
- $xml=simplexml_load_string($data);
- }
- }
- //Will play something
- if($_POST['action'] == 'playit') {
- if ($xml === false) {
- echo "Failed loading XML: Check Password and make sure VLC is running ";
- foreach(libxml_get_errors() as $error) {
- echo "<br>", $error->message;
- }
- } else {
- //Build URL in here return filename & update status
- $vlcfilename = $_POST['filename'];
- $fullvlcplayurl = $playurl . $filelocation . $vlcfilename;
- $stopdata = file_get_contents("http://$stopurl", false, $context);
- $cleardata = file_get_contents("http://$clearplurl", false, $context);
- $playdata = file_get_contents("http://$fullvlcplayurl", false, $context);
- //sleep(1); Wont go into full screen unless delayed for a second. Will sort a if statement out with the xml
- //$fullscreendata = file_get_contents("http://$fullscreenurl", false, $context);
- sleep(1);
- $finalstatus = file_get_contents("http://$server", false, $context);
- $xmlnew=simplexml_load_string($finalstatus);
- $fullscreenstatus = $xmlnew->fullscreen; //States from the xml
- $vlcstate = $xml->state;
- echo "VLC is currently " . $vlcstate . ". Fullscreen? ". $fullscreenstatus ."!";
- }
- }
- //Deletes requested file - forever
- if($_POST['action'] == 'deleteit') {
- $filenamedelete = $_POST['filename'];
- $filenamedelete1= str_replace("%20"," ",$filenamedelete);
- $deletepath = $filelocation . $filenamedelete1;
- if (!unlink($deletepath))
- {
- echo ("Error deleting $deletepath Check permissions and try again.");
- }
- else
- {
- echo ("Success page will reload");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement