Advertisement
Guest User

query

a guest
Mar 13th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <?php
  2. // PHP script to get status of vlc because javascript is shit
  3. $username = '';
  4. $password = '1234';
  5. $server = 'localhost:8080/requests/status.xml';
  6. $fullscreenurl = 'localhost:8080/requests/status.xml?command=fullscreen';
  7. $clearplurl = 'localhost:8080/requests/status.xml?command=pl_empty';
  8. $stopurl = 'localhost:8080/requests/status.xml?command=pl_pause';
  9. $playurl = 'localhost:8080/requests/status.xml?command=in_play&input=';
  10. $filelocation = '\\\\NasDrive\\Library\\movies\\';
  11.  
  12. $context = stream_context_create(array( //needed to authorise VLC
  13. 'http' => array(
  14. 'header' => "Authorization: Basic " . base64_encode("$username:$password")
  15. )
  16. )
  17. );
  18.  
  19. //Checks status
  20. $data = file_get_contents("http://$server", false, $context);
  21. $xml=simplexml_load_string($data);
  22. if($_POST['action'] == 'checkit') {
  23. if ($xml === false) {
  24. echo "Failed loading XML: Check Password and make sure VLC is running ";
  25. foreach(libxml_get_errors() as $error) {
  26. echo "<br>", $error->message;
  27. }
  28. } else {
  29. $data = file_get_contents("http://$server", false, $context);
  30. $xml=simplexml_load_string($data);
  31. $fullscreenstatus = $xml->fullscreen; //States from the xml
  32. $vlcstate = $xml->state;
  33.  
  34. echo "VLC is currently " . $vlcstate . ". Fullscreen? ". $fullscreenstatus ."";
  35. }
  36. }
  37. // Toggles fullscreen
  38. if($_POST['action'] == 'fullscreen') {
  39. if ($xml === false) {
  40. echo "Failed loading XML: Check Password and make sure VLC is running ";
  41. foreach(libxml_get_errors() as $error) {
  42. echo "<br>", $error->message;
  43. }
  44. } else {
  45. $data = file_get_contents("http://$fullscreenurl", false, $context);
  46. $xml=simplexml_load_string($data);
  47. }
  48. }
  49.  
  50. //Will play something
  51. if($_POST['action'] == 'playit') {
  52. if ($xml === false) {
  53. echo "Failed loading XML: Check Password and make sure VLC is running ";
  54. foreach(libxml_get_errors() as $error) {
  55. echo "<br>", $error->message;
  56. }
  57. } else {
  58.  
  59. //Build URL in here return filename & update status
  60. $vlcfilename = $_POST['filename'];
  61. $fullvlcplayurl = $playurl . $filelocation . $vlcfilename;
  62. $stopdata = file_get_contents("http://$stopurl", false, $context);
  63. $cleardata = file_get_contents("http://$clearplurl", false, $context);
  64. $playdata = file_get_contents("http://$fullvlcplayurl", false, $context);
  65. //sleep(1); Wont go into full screen unless delayed for a second. Will sort a if statement out with the xml
  66. //$fullscreendata = file_get_contents("http://$fullscreenurl", false, $context);
  67. sleep(1);
  68. $finalstatus = file_get_contents("http://$server", false, $context);
  69. $xmlnew=simplexml_load_string($finalstatus);
  70. $fullscreenstatus = $xmlnew->fullscreen; //States from the xml
  71. $vlcstate = $xml->state;
  72. echo "VLC is currently " . $vlcstate . ". Fullscreen? ". $fullscreenstatus ."!!!!!!!!!";
  73. }
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement