Advertisement
Guest User

test

a guest
Dec 6th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.50 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4.  
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <title>Oppla TV</title>
  8. <script src="https://code.jquery.com/jquery-3.3.1.min.js"
  9. integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
  10. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
  11. integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
  12. crossorigin="anonymous"></script>
  13. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
  14. integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  15.  
  16. <script src="https://cdn.jsdelivr.net/bluebird/3.5.0/bluebird.min.js"></script>
  17. <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/2.0.3/fetch.js"></script>
  18.  
  19.  
  20. <script type="text/javascript" src="$MANAGER_WIDGET/Common/API/Widget.js"></script>
  21. <script type="text/javascript" src="$MANAGER_WIDGET/Common/API/TVKeyValue.js"></script>
  22. <script type="text/javascript" src="$MANAGER_WIDGET/Common/af/2.0.0/loader.js"></script>
  23. <script type="text/javascript" src="JavaScript/Main.js"></script>
  24.  
  25. <script >
  26. var ip = null
  27.  
  28. var BASE_LINK = "http://minegiammi.altervista.org/oppla_script/checkStreamingLinkToTV.php";
  29.  
  30. var connected = false;
  31. var public_ip = null;
  32.  
  33. var check_interval = null
  34. var link = null;
  35.  
  36. var interval_sec = 500;
  37.  
  38. var Main = { // Main object
  39. }
  40.  
  41. try {
  42. var widgetAPI = new Common.API.Widget(); // Creates Common module
  43. var tvKey = new Common.API.TVKeyValue();
  44. } catch (e) {
  45. console.error(e);
  46. }
  47.  
  48. Main.onLoad = function () { // called by body's onload event
  49.  
  50. try {
  51. sf.service.VideoPlayer.init({
  52. onstatechange: function (state) {
  53. //alert('Current State : ' + state);
  54. },
  55. onend: function () {
  56. returnToMainScreen()
  57. },
  58. onerror: function (error) {
  59. returnToMainScreen()
  60. }
  61. });
  62. sf.service.VideoPlayer.setFullScreen(true);
  63. sf.service.VideoPlayer.setPosition({
  64. left: 0,
  65. top: 0,
  66. width: 960,
  67. height: 540
  68. });
  69. sf.service.VideoPlayer.hide();
  70.  
  71. sf.service.VideoPlayer.setKeyHandler(sf.key.RETURN, function () {
  72. sf.service.VideoPlayer.stop();
  73. returnToMainScreen()
  74. });
  75.  
  76. widgetAPI.sendReadyEvent(); // Sends ready message to Application Manager
  77. } catch (e) {
  78. console.error(e);
  79. }
  80.  
  81. setSize();
  82. showLoadingPage()
  83. $.getJSON('http://ipinfo.io', function (data) {
  84. public_ip = data["ip"];
  85. //public_ip = public_ip.replace(/\./g, "");
  86.  
  87. sendReadyState();
  88. check_interval = setInterval(check_if_link_ready, interval_sec)
  89. });
  90. }
  91.  
  92. function returnToMainScreen() {
  93. showLoadingPage();
  94. link = null;
  95. sendReadyState();
  96. check_interval = setInterval(check_if_link_ready, interval_sec)
  97. }
  98.  
  99. function sendReadyState() {
  100. fetch(BASE_LINK + "?type=ready&ip=" + public_ip, {
  101. method: "GET"
  102. })
  103. .then(function (data) { return data.text() })
  104. .then(function (html) {
  105. //console.log(html);
  106. })
  107. .catch(function (e) {
  108. console.error(e)
  109. })
  110. }
  111.  
  112. function closeConnection() {
  113. fetch(BASE_LINK + "?type=close&ip=" + public_ip, {
  114. method: "GET"
  115. })
  116. .then(function (data) { return data.text() })
  117. .then(function (html) {
  118. //console.log(html);
  119. })
  120. }
  121.  
  122. Main.enableKeys = function () {
  123. document.getElementById("anchor").focus();
  124.  
  125. }
  126.  
  127. Main.keyDown = function () { // Key handler
  128. var keyCode = event.keyCode;
  129.  
  130. switch (keyCode) {
  131. case tvKey.KEY_PAUSE:
  132. $('#video').trigger('pause');
  133. break;
  134. case tvKey.KEY_PLAY:
  135. $('#video').trigger('play');
  136. break;
  137. case tvKey.KEY_FF:
  138. // fast forward
  139. $('#video').prop("currentTime", $('#video').prop("currentTime") + 5);
  140. break;
  141. case tvKey.KEY_RW:
  142. // rewind
  143. $('#video').prop("currentTime", $('#video').prop("currentTime") - 5);
  144. break;
  145. case KEY_MUTE:
  146. $('#video').prop("muted", !$('#video').prop("muted"));
  147. break;
  148. case KEY_WHEELUP:
  149. //$('#video').prop("muted", !$('#video').prop("muted"));
  150. $("#video").prop("volume", $("#video").prop("volume") + 0.1);
  151. break;
  152. case KEY_WHEELDOWN:
  153. //$('#video').prop("muted", !$('#video').prop("muted"));
  154. $("#video").prop("volume", $("#video").prop("volume") - 0.1);
  155. break;
  156. case KEY_ENTER:
  157. document.getElementById("video").focus();
  158. break;
  159. }
  160. }
  161.  
  162. Main.onUnload = function () {
  163. closeConnection();
  164. }
  165.  
  166. function setSize() {
  167. var height = 540;
  168. var width = 960;
  169. $("#container").css("height", height + "px");
  170. $("#container").css("width", width + "px");
  171. $("#loading-area").css("margin-top", (height / 2 - ($("#loading").width() + 40 + 4)) + "px");
  172. }
  173.  
  174. window.onresize = function () {
  175. setSize()
  176. }
  177.  
  178. function openFullscreen() {
  179. var elem = document.getElementById("video");
  180. if (elem.requestFullscreen) {
  181. elem.requestFullscreen();
  182. } else if (elem.mozRequestFullScreen) { /* Firefox */
  183. elem.mozRequestFullScreen();
  184. } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
  185. elem.webkitRequestFullscreen();
  186. } else if (elem.msRequestFullscreen) { /* IE/Edge */
  187. elem.msRequestFullscreen();
  188. }
  189. }
  190.  
  191. function closeFullscreen() {
  192. if (document.exitFullscreen) {
  193. document.exitFullscreen();
  194. } else if (document.mozCancelFullScreen) { /* Firefox */
  195. document.mozCancelFullScreen();
  196. } else if (document.webkitExitFullscreen) { /* Chrome, Safari and Opera */
  197. document.webkitExitFullscreen();
  198. } else if (document.msExitFullscreen) { /* IE/Edge */
  199. document.msExitFullscreen();
  200. }
  201. }
  202.  
  203. function check_if_link_ready() {
  204. if (link != null) {
  205. clearInterval(check_interval)
  206. } else {
  207. //console.log(BASE_LINK + "?type=read&ip=" + public_ip);
  208. fetch(BASE_LINK + "?type=read&ip=" + public_ip, {
  209. method: "GET",
  210. headers: {
  211.  
  212. }
  213. })
  214. .then(function (data) { return data.text() })
  215. .then(function (html) {
  216. link = null;
  217. if (html != "error" && html != "" && html != "ready" && html != null) {
  218. console.log(html);
  219. link = html;
  220. playVideo(link);
  221. }
  222. })
  223. }
  224. }
  225.  
  226. function playVideo(link) {
  227. $("#message").html("QUASI PRONTO DAMMI UN SECONDO E CI SONO!");
  228.  
  229. try {
  230. sf.service.VideoPlayer.show();
  231. sf.service.VideoPlayer.play({
  232. url: link,
  233. fullScreen: true
  234. });
  235. } catch (e) {
  236. console.error(e)
  237. }
  238.  
  239.  
  240. $('#video').prop("src", link);
  241. $('#video').prop("muted", false);
  242. $('#video').trigger('play')
  243. $('#video').on("loadeddata", function () {
  244. showVideoPage();
  245. document.getElementById("video").focus();
  246. //openFullscreen();
  247. })
  248. }
  249.  
  250. function showVideoPage() {
  251. // SHOW VIDEO AND HIDE LOADIND
  252. $("#message").html("UFFF DAI CHE VOGLIO GUARDARE IL FILM");
  253. $("#container").css("display", "none");
  254. $("#video").css("display", "");
  255. }
  256.  
  257. function showLoadingPage() {
  258. // SHOW VIDEO AND HIDE LOADIND
  259. try {
  260. sf.service.VideoPlayer.hide();
  261. } catch (e) {
  262. console.error(e)
  263. }
  264.  
  265. $("#message").html("UFFF DAI CHE VOGLIO GUARDARE IL FILM");
  266. $("#video").css("display", "none");
  267. $("#container").css("display", "");
  268. }
  269.  
  270. function searchRedirect(link) {
  271. try {
  272.  
  273. var http = new XMLHttpRequest();
  274. http.open('HEAD', link);
  275. http.onreadystatechange = function () {
  276. if (this.readyState === this.DONE) {
  277. var new_link = this.responseURL;
  278. if(new_link != null) link = new_link;
  279. console.log("LINK : " + link);
  280. playVideo(link);
  281. }
  282. };
  283. http.send();
  284. } catch (e) {
  285. console.error(e);
  286. playVideo(link);
  287. }
  288. }
  289.  
  290. </script>
  291.  
  292. <link rel="stylesheet" type="text/css" href="CSS/Main.css" />
  293. </head>
  294.  
  295. <body onload="Main.onLoad();" onunload="Main.onUnload()" onkeydown="Main.keyDown();"
  296. style="background-color: #171D22; color: white; font-family: calibri ">
  297. <div class="container-fluid" id="container" style="border: 1px transparent solid;">
  298. <div id="loading-area" style="display: ''">
  299. <div class="mb-4" style="text-align: center">
  300. <div id="message" class="" style="font-size: 40px; font-weight:400">
  301. UFFF DAI CHE VOGLIO GUARDARE IL FILM
  302. </div>
  303. </div>
  304. <div class="" style="text-align: center">
  305. <div class="spinner-border text-light" id="loading" role="status" style="width: 4rem; height: 4rem;">
  306. <span class="sr-only">Loading...</span>
  307. </div>
  308. </div>
  309. </div>
  310. </div>
  311. <video id="video" src="" controls style="display: none"></video>
  312. </body>
  313.  
  314. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement