index.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <?php
  2. include_once '../auth.php';
  3. if (isset($_GET['filepath'])){
  4. header("Location: embedded.php?filepath=" . $_GET['filepath'] . "&filename=" . $_GET['filename']);
  5. }
  6. ?>
  7. <html>
  8. <head>
  9. <link rel="stylesheet" href="../script/tocas/tocas.css">
  10. <script src="../script/tocas/tocas.js"></script>
  11. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  12. <script src="../script/jquery.min.js"></script>
  13. <script src="../script/ao_module.js"></script>
  14. <link rel="manifest" href="manifest.json">
  15. <style>
  16. body{
  17. background-color:#0c0c0c;
  18. color:white;
  19. }
  20. .white{
  21. color:white !important;
  22. }
  23. .bottom{
  24. position:fixed;
  25. width:100%;
  26. height:35px;
  27. left:0px;
  28. bottom:0px;
  29. padding-bottom:5px;
  30. padding: 5px;
  31. }
  32. </style>
  33. </head>
  34. <?php
  35. $rid = rand(1000,9999);
  36. ?>
  37. <body>
  38. <br>
  39. </body>
  40. <script>
  41. //may need update after iPadOS update.
  42. var iOS = !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
  43. var currDisplay = "idle";
  44. var video = document.getElementById("video");
  45. var audio = new Audio("");
  46. loadScreen();
  47. var rid = $("#rid").text().trim();
  48. ao_module_setWindowSize(395,520);
  49. ao_module_setWindowTitle("RemotePlay");
  50. ao_module_setWindowIcon("feed");
  51. if (ao_module_virtualDesktop){
  52. $(".dirModeOnly").hide();
  53. }
  54. setInterval(check,1000);
  55. function check(){
  56. $.get("check.php?rid=" + rid,function(data){
  57. if (data.includes("ERROR") == false){
  58. if (data[0] == false){
  59. //Nothing is found
  60. }else{
  61. //There is content. Read it from JSON
  62. var fileinfo = data[1];
  63. console.log(fileinfo[1]);
  64. if (fileinfo[0] == "fopen"){
  65. $.get("opr.php?opr=mime&file=" + fileinfo[1],function(filetype){
  66. audio.pause();
  67. audio.currentTime = 0;
  68. //open the given filepath
  69. if(filetype == "image"){
  70. $("body").html('<img src="' + fileinfo[1] + '" style="height: 100%;display: block;margin-left: auto;margin-right: auto;"></img');
  71. currDisplay = "image";
  72. ao_module_setWindowSize(800,800);
  73. }else if(filetype == "video"){
  74. $("body").html('<video autoplay loop id="video" style="height: 100%;display: block;margin-left: auto;margin-right: auto;width: 100%;"><source src="' + fileinfo[1] + '" type="video/mp4"></video><div class="ts snackbar"><div class="content"></div></div>');
  75. video = document.querySelector('video');
  76. var promise = video.play();
  77. if (promise !== undefined) {
  78. promise.then(_ => {
  79. }).catch(error => {
  80. video.muted = true;
  81. video.play();
  82. ts('.snackbar').snackbar({
  83. content: 'Due to browser restricton, this video has been muted.',
  84. action: '',
  85. actionEmphasis: 'negative',
  86. });
  87. });
  88. }
  89. currDisplay = "video";
  90. ao_module_setWindowSize(800,800);
  91. video = document.getElementById("video");
  92. }else if(filetype == "audio"){
  93. loadScreen();
  94. audio.volume = localStorage.getItem("global_volume");
  95. audio.loop = true;
  96. audio.pause();
  97. audio.currentTime = 0;
  98. audio.src = fileinfo[1];
  99. //audio.play();
  100. var promise = audio.play();
  101. if (promise !== undefined) {
  102. promise.then(_ => {
  103. }).catch(error => {
  104. //audio.muted = true;
  105. //audio.play();
  106. ts('.snackbar').snackbar({
  107. content: 'Due to browser restricton, audio can\'t stream to this device',
  108. action: '',
  109. actionEmphasis: 'negative',
  110. });
  111. //alert("Error");
  112. });
  113. }
  114. currDisplay = "audio";
  115. ao_module_setWindowSize(395,520);
  116. }
  117. });
  118. }else if (fileinfo[0] == "setVol"){
  119. localStorage.setItem("global_volume",fileinfo[1]);
  120. if(currDisplay == "audio"){
  121. audio.volume = localStorage.getItem("global_volume");
  122. }else if(currDisplay == "video"){
  123. video.volume = localStorage.getItem("global_volume");
  124. }
  125. }else if (fileinfo[0] == "volup"){
  126. if(currDisplay == "audio"){
  127. localStorage.setItem("global_volume",audio.volume + 0.1);
  128. audio.volume = audio.volume + 0.1
  129. }else if(currDisplay == "video"){
  130. localStorage.setItem("global_volume",video.volume + 0.1);
  131. video.volume = video.volume + 0.1
  132. }
  133. }else if (fileinfo[0] == "voldown"){
  134. if(currDisplay == "audio"){
  135. localStorage.setItem("global_volume",audio.volume - 0.1);
  136. audio.volume = audio.volume - 0.1
  137. }else if(currDisplay == "video"){
  138. localStorage.setItem("global_volume",video.volume - 0.1);
  139. video.volume = video.volume - 0.1
  140. }
  141. }else if (fileinfo[0] == "play"){
  142. if(currDisplay == "audio"){
  143. audio.play();
  144. }else if(currDisplay == "video"){
  145. video.play();
  146. }
  147. }else if (fileinfo[0] == "pause"){
  148. if(currDisplay == "audio"){
  149. audio.pause();
  150. }else if(currDisplay == "video"){
  151. video.pause();
  152. }
  153. }else if (fileinfo[0] == "fwd"){
  154. if(currDisplay == "audio"){
  155. audio.currentTime = audio.currentTime + 15;
  156. }else if(currDisplay == "video"){
  157. video.currentTime = video.currentTime + 15;
  158. }
  159. }else if (fileinfo[0] == "bwd"){
  160. if(currDisplay == "audio"){
  161. audio.currentTime = audio.currentTime - 15;
  162. }else if(currDisplay == "video"){
  163. video.currentTime = video.currentTime - 15;
  164. }
  165. }else if (fileinfo[0] == "stop"){
  166. if(currDisplay == "audio"){
  167. audio.pause();
  168. audio.currentTime = 0;
  169. }else if(currDisplay == "video"){
  170. video.pause();
  171. video.currentTime = 0;
  172. }
  173. }else if(fileinfo[0] == "reset"){
  174. loadScreen();
  175. }else if(fileinfo[0] == "newsession"){
  176. location.reload();
  177. }
  178. }
  179. /* end */
  180. }
  181. });
  182. }
  183. function loadScreen(){
  184. $("body").html(`
  185. <br><br>
  186. <div class="ts container" style="color:white;">
  187. <h3 class="ts center aligned icon header" style="color:white;">
  188. <i class="feed icon"></i>ArOZ Remote Play
  189. <div class="sub header" style="color:white;">Use this devices as a remote player or player remote!</div>
  190. <hr>
  191. </h3>
  192. <div align="center">
  193. <div class="white" style="font-size:2em;padding-top:10px;"><i class="hashtag icon"></i>Remote ID: <?php echo $rid;?></div>
  194. <p class="white" style="font-size:80%;">To use ArOZ Remote Play function, use the OpenWith from your active device and enter the above ID to play with this window.<br><!--<i class="caution sign icon"></i>Warning! Only support Audio files.</p>-->
  195. </div>
  196. <br>
  197. </div>
  198. <div class="white bottom" align="right">
  199. <div class="ts breadcrumb">
  200. <a class="white section" href="mobileremote.php">Toggle P-Remote</a>
  201. <div class="divider"> / </div>
  202. <a class="white section" href="remote.php">Toggle Remote</a>
  203. <div class="divider"> / </div>
  204. <a class="white section" href="">Refresh</a>
  205. <div class="divider"> / </div>
  206. <a class="white section">Clear Sessions</a>
  207. <div class="divider dirModeOnly"> / </div>
  208. <a class="white active section dirModeOnly" href="../">Exit</a>
  209. </div>
  210. </div>
  211. <div class="ts snackbar"><div class="content"></div></div>
  212. <div id="rid" style="display:none;"><?php echo $rid;?></div>
  213. `);
  214. }
  215. </script>
  216. </html>