remote.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. include_once '../auth.php';
  3. if(!file_exists("data")){
  4. mkdir("data",0777,true);
  5. }
  6. if (isset($_GET['comm']) && isset($_GET['rid'])){
  7. $rid = $_GET['rid'];
  8. $rid = explode(",",$rid)[0];
  9. file_put_contents("data/" . $rid . ".inf",$_GET['comm']);
  10. echo "DONE";
  11. exit(0);
  12. }
  13. ?>
  14. <html>
  15. <head>
  16. <link rel="stylesheet" href="../script/tocas/tocas.css">
  17. <script src="../script/tocas/tocas.js"></script>
  18. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  19. <script src="../script/jquery.min.js"></script>
  20. <script src="../script/ao_module.js"></script>
  21. <link rel="manifest" href="manifest.json">
  22. <style>
  23. body{
  24. background-color:#0c0c0c;
  25. color:white;
  26. }
  27. .white{
  28. color:white !important;
  29. }
  30. ::placeholder{
  31. color: white !important;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <br>
  37. <div class="ts container">
  38. <div class="ts white header">
  39. <i class="options icon"></i>RemotePlay Remote
  40. <div class="sub white header">Control your remote player here!</div>
  41. </div>
  42. <p class="white">Target RemotePlay ID</p>
  43. <div class="ts floating dropdown labeled icon button" style="padding: 0px;padding-right: calc(0.22em + 1em + .78571em * 2) !important;padding-left: 0em !important;background-color: black;color:white;height: 39.97px;width:100%">
  44. <div class="text" style="width:100%">
  45. <div class="ts fluid input" style="right 1px;bottom:1px">
  46. <input type="text" style="border-top-right-radius: 0px;border-bottom-right-radius: 0px;background-color: black;color: white!important;border-color: white!important;border-right:0px" placeholder="RemotePlay ID" id="remoteID_tb">
  47. </div>
  48. </div>
  49. <i class="caret down icon" style="left: auto !important;right: 0em !important;background-color: black;"></i>
  50. <div class="menu" style="background-color: black !important;" id="n_remoteID">
  51. </div>
  52. </div>
  53. <!--
  54. <div class="ts basic mini fluid input">
  55. <select class="ts basic dropdown" id="remoteID" style="background: black;color: white;width: 100%">
  56. <option>Scanning...</option>
  57. </select>
  58. </div>
  59. -->
  60. <p class="white">Volume Control (Min <--> Max)</p>
  61. <div class="ts slider">
  62. <input id="vol" type="range" min="0" max="1" step="0.05" value="0">
  63. </div>
  64. <br>
  65. <div class="ts separated mini buttons">
  66. <button class="ts basic white button" onClick="play();"><i class="play icon"></i>Play</button>
  67. <button class="ts basic white button" onClick="pause();"><i class="pause icon"></i>Pause</button>
  68. <button class="ts basic white button" onClick="bwd();"><i class="backward icon"></i>Backward</button>
  69. <button class="ts basic white button" onClick="fwd();"><i class="forward icon"></i>Forward</button>
  70. <button class="ts basic white button" onClick="fbwd();"><i class="fast backward icon"></i>Fast backward</button>
  71. <button class="ts basic white button" onClick="ffwd();"><i class="fast forward icon"></i>Fast forward</button>
  72. <button class="ts basic white button" onClick="stop();"><i class="stop icon"></i>Stop</button>
  73. <button class="ts basic white button" onClick="mute();"><i class="volume off icon"></i>Mute</button>
  74. <button class="ts basic white button" onClick="reset();"><i class="stop icon"></i>Reset</button>
  75. </div>
  76. </div>
  77. <script>
  78. var rid = "";
  79. $(document).ready(function(){
  80. ao_module_setWindowSize(1000,340);
  81. ts('.ts.dropdown:not(.basic)').dropdown();
  82. $(".ts.fluid.input").click(function(e) {
  83. e.stopPropagation();
  84. });
  85. var h = $(".ts.fluid.input").height();
  86. $(".ts.floating.dropdown.labeled.icon.button").attr("style",$(".ts.floating.dropdown.labeled.icon.button").attr("style").replace("39.97",h));
  87. //$(".caret.down.icon").attr("style",$(".caret.down.icon").attr("style").replace("39.97",h));
  88. update();
  89. });
  90. setInterval(update, 10000);
  91. function update(){
  92. var previousRemoteID = ao_module_getStorage("remoteplay","remoteID");
  93. $.get("opr.php?opr=scanalive",function(data){
  94. var obj = JSON.parse(data);
  95. $("#n_remoteID").html("");
  96. $("#n_remoteID").append($('<div class="item" style="color: white!important;"></div>').attr("value", "").text("Not selected"));
  97. $.each( obj, function( key, value ) {
  98. $("#n_remoteID").append($('<div class="item" style="color: white!important;"></div>').attr("value", value).text(value));
  99. });
  100. $("#n_remoteID").val("");
  101. /*
  102. if (previousRemoteID !== undefined && $(".item[value='" + previousRemoteID + "']").length > 0){
  103. $("#remoteID_tb").val(previousRemoteID);
  104. rid = previousRemoteID;
  105. }
  106. */
  107. $("#remoteID_tb").val(previousRemoteID);
  108. $("#n_remoteID .item").on("click",function(){
  109. //console.log($(this).attr("value"));
  110. $("#remoteID_tb").val($(this).attr("value"));
  111. ao_module_saveStorage("remoteplay","remoteID",$(this).attr("value"));
  112. rid = $(this).attr("value");
  113. });
  114. $("#remoteID_tb").on("change",function(){
  115. ao_module_saveStorage("remoteplay","remoteID",$(this).val());
  116. rid = $(this).val();
  117. });
  118. });
  119. }
  120. $("#vol").on("change",function(){
  121. sendCommand("setVol",$(this).val());
  122. });
  123. function play(){
  124. sendCommand("play","");
  125. }
  126. function pause(){
  127. sendCommand("pause","");
  128. }
  129. function fwd(){
  130. sendCommand("fwd","");
  131. }
  132. var ffwding = false;
  133. function ffwd(){
  134. if(ffwding){
  135. clearInterval(timer_1);
  136. ffwding = false;
  137. $("button").removeAttr("disabled");
  138. $("#vol").removeAttr("disabled");
  139. }else{
  140. timer_1 = setInterval(fwd, 1000);
  141. ffwding = true;
  142. $("#vol").attr("disabled","disabled");
  143. $("button").attr("disabled","disabled");
  144. $(".fast.forward.icon").parent().removeAttr("disabled");
  145. }
  146. }
  147. function bwd(){
  148. sendCommand("bwd","");
  149. }
  150. var fbwding = false;
  151. function fbwd(){
  152. if(fbwding){
  153. clearInterval(timer_1);
  154. fbwding = false;
  155. $("button").removeAttr("disabled");
  156. $("#vol").removeAttr("disabled");
  157. }else{
  158. timer_1 = setInterval(bwd, 1000);
  159. fbwding = true;
  160. $("#vol").attr("disabled","disabled");
  161. $("button").attr("disabled","disabled");
  162. $(".fast.backward.icon").parent().removeAttr("disabled");
  163. }
  164. }
  165. function stop(){
  166. sendCommand("stop","");
  167. }
  168. function mute(){
  169. sendCommand("setVol","0");
  170. $("#vol").val(0);
  171. }
  172. function reset(){
  173. sendCommand("reset","");
  174. }
  175. function sendCommand(comm,value){
  176. var fullcomm = comm + "," + value;
  177. $.get("remote.php?comm=" + fullcomm + "&rid=" + rid,function(data){
  178. if (data.includes("ERROR")){
  179. }
  180. });
  181. }
  182. /*
  183. $(document).ready(function(){
  184. var previousRemoteID = ao_module_getStorage("remoteplay","remoteID");
  185. $.get("opr.php?opr=scanalive",function(data){
  186. var obj = JSON.parse(data);
  187. $("#remoteID").html("");
  188. $("#remoteID").append($("<option></option>").attr("value", "").text("Not selected"));
  189. $.each( obj, function( key, value ) {
  190. $("#remoteID").append($("<option></option>").attr("value", value).text(value));
  191. });
  192. $("#remoteID").val("");
  193. if (previousRemoteID !== undefined && $("#remoteID option[value='" + previousRemoteID + "']").length > 0){
  194. $("#remoteID").val(previousRemoteID);
  195. rid = previousRemoteID;
  196. }
  197. });
  198. });
  199. */
  200. </script>
  201. </body>
  202. </html>