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\\movies\\';
- $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;
- echo "VLC is currently " . $vlcstate . ". Fullscreen? ". $fullscreenstatus ."";
- }
- }
- // 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 ."!!!!!!!!!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement