WXtrialInterface.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>双子星</title>
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="x5-orientation" content="portrait" />
  8. <meta name="screen-orientation" content="portrait" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <!-- 删除苹果默认的工具栏和菜单栏 -->
  12. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  13. <!-- 设置苹果工具栏颜? -->
  14. <meta name="format-detection" content="telphone=no, email=no">
  15. <!-- 忽略页面中的数字识别为电话,忽略email识别 -->
  16. <!-- 启用360浏览器的极速模?(webkit) -->
  17. <meta name="renderer" content="webkit">
  18. <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑? -->
  19. <meta name="HandheldFriendly" content="true">
  20. <!-- 微软的老式浏览? -->
  21. <meta name="MobileOptimized" content="320">
  22. <!-- 不能旋转,问题出在这 -->
  23. <!-- UC强制全屏 -->
  24. <meta name="full-screen" content="yes">
  25. <!-- QQ强制全屏 -->
  26. <meta name="x5-fullscreen" content="true">
  27. <!-- UC应用模式 -->
  28. <meta name="browsermode" content="application">
  29. <!-- QQ应用模式 -->
  30. <meta name="x5-page-mode" content="app">
  31. <!-- windows phone 点击无高? -->
  32. <meta name="msapplication-tap-highlight" content="no">
  33. <link rel="stylesheet" type="text/css" href="css/WXtrialInterface.css" />
  34. <link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
  35. <link rel="stylesheet" href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css">
  36. </head>
  37. <body class="scroll h-player" style="overscroll-behavior: contain;">
  38. <div class="container" id="player">
  39. <div class="muted" id="btnMuted">
  40. <div class="control-right-img" data-id="1">
  41. <img src="../static/img/xuanfu_icon.png">
  42. </div>
  43. </div>
  44. <div id="wine">
  45. <video id="playerVideo" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
  46. webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false"
  47. style="pointer-events: none;object-fit: fill;width: 100%;height:100%"></video>
  48. <div id="box"></div>
  49. <audio preload="auto" autoplay controls poster="images/loader-thumb.jpg" id="audioPlayer"
  50. style="position: absolute;top: 0;width: 0;height: 0;"></audio>
  51. </div>
  52. <div class="leftmains">
  53. <div class="PictureQualityMain">
  54. <div class="PictureQuality " data-id="3072000">高清</div>
  55. <div class="PictureQuality avit" data-id="2243000">标清</div>
  56. <div class="PictureQuality" data-id="400000">极速</div>
  57. <div class="PictureQuality" data-id="400000">自动</div>
  58. </div>
  59. <div class="operation">
  60. <div class="upload" id="showsuss" data-text="uploads">
  61. <img src="../static/img/wx/shangchuan_icon.png">
  62. <div>上传</div>
  63. </div>
  64. <div class="upload" onclick="cp(document.getElementById('user_ref_id'));" data-text="Shearplate">
  65. <img src="../static/img/wx/jianqieban_icon.png">
  66. <div>剪切板</div>
  67. </div>
  68. <div class="upload" id="upload" data-text="Signout">
  69. <img src="../static/img/wx/tuichu_icon.png">
  70. <div>退出</div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="bottommains">
  75. <div class="botmat1">
  76. <div class="botmat1img" data-text="gengduo">
  77. <img src="../static/img/wx/gengduo_icon.png">
  78. </div>
  79. </div>
  80. <div class="botmat1">
  81. <div class="botmat1img" data-text="home">
  82. <img src="../static/img/wx/home_icon.png">
  83. </div>
  84. </div>
  85. <div class="botmat1">
  86. <div class="botmat1img" data-text="return">
  87. <img src="../static/img/wx/fanhui_icon.png">
  88. </div>
  89. </div>
  90. </div>
  91. <div class="mainbox" style="display: none;">
  92. <div class="boxTitle">提示</div>
  93. <div class="boxText">
  94. <div>由于小程序的功能限制,此功能暂时</div>
  95. <div>无法使用,请下载APP使用更多功能</div>
  96. </div>
  97. <div class="boxbt" onclick="cp(document.getElementById('user_ref_id'));">立即前往下载</div>
  98. <div class="boximg"><img src="../static/img/wx/guanbi_icon.png"></div>
  99. </div>
  100. <div class="sbox" style="display: none;">
  101. <div class="sboxText">下载地址已复制到剪切板</div>
  102. <div class="sboxbu">确定</div>
  103. </div>
  104. <div class="loading"></div>
  105. </div>
  106. <div class="weui-mask_transparent"></div>
  107. <div class="weui-toast weui_loading_toast weui-toast--visible">
  108. <div class="weui_loading"><i class="weui-loading weui-icon_toast"></i></div>
  109. <p class="weui-toast_content">数据加载中</p>
  110. </div>
  111. <body oncontextmenu="Back()">
  112. </body>
  113. <div id="copy-txt" style="position: absolute;opacity: 0;">
  114. <span id="user_ref_id">www.androidsCloud.com</span>
  115. </div>
  116. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  117. <script type="text/javascript" src="../static/js/jquery-1.11.0.min.js"></script>
  118. <script type="text/javascript" src="helper.js"></script>
  119. <script type="text/javascript" src="pcm-player.js"></script>
  120. <script type="text/javascript" src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  121. <script type="text/javascript" src="WXdraw.js?v=110"></script>
  122. <script type="text/javascript" src="jmuxer.js"></script>
  123. <script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  124. <script>
  125. var isAudioPlay = false;
  126. $.alert({
  127. title: '提示',
  128. text: '开始使用云手机',
  129. onOK: function () {
  130. var video = document.getElementById("playerVideo");
  131. video.play();
  132. isAudioPlay = true;
  133. $('.weui-mask_transparent').hide();
  134. $('.weui-toast').hide();
  135. $('.loading').hide();
  136. }
  137. });
  138. // document.addEventListener('touchstart', function () {
  139. // var video = document.getElementById("playerVideo");
  140. // var audio = document.getElementById("audioPlayer");
  141. // video.play();
  142. // audio.play();
  143. // }, false);
  144. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  145. $('#wine').css({
  146. "width": window.screen.width,
  147. "height": window.screen.height - topwinHeight - 20,
  148. "position": "absolute"
  149. });
  150. $('.loading').css({
  151. "width": window.screen.width,
  152. "height": window.screen.height - topwinHeight - 20
  153. });
  154. var winese = document.createElement("wine");
  155. wine.style.top = "-" + winese + 'px';
  156. var requestCount = 0;
  157. var isVisuable = true;
  158. var isFeed = true;
  159. var isDrag = false;
  160. var isEnough = true;
  161. var isFinish = false;
  162. var delayTime = new Date().getTime();
  163. var curTime = new Date().getTime();
  164. var myVideo = document.getElementById("playerVideo");
  165. Module = {};
  166. Module.onRuntimeInitialized = function () {
  167. isFinish = true;
  168. }
  169. var isWSS = false;
  170. var room = ['test.androidscloud.com', 'vclusters.imwork.net:2221'];
  171. var parameters = GetRequest();
  172. var ip = parameters["ip"];
  173. var room = parameters["rm"];
  174. var wsUrl;
  175. if (room == "A1") {
  176. wsUrl = room[0];
  177. } else {
  178. wsUrl = room[1];
  179. }
  180. var socketURL = isWSS ? "wss" : "ws" + "://" + wsUrl + "/card?cardIp=" + ip;
  181. var jmuxer = new JMuxer({
  182. node: 'playerVideo',
  183. flushingTime: 15,
  184. fps: 30,
  185. mode: 'video',
  186. debug: false
  187. });
  188. window.onload = function () {
  189. curTime = new Date().getTime();
  190. var myPlay = document.getElementById("wine");
  191. // myPlay.onmousedown = function (event) {
  192. // if (event.button == 0) {
  193. // var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  194. // var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  195. // var buffer = ExexuteMouseDown(posX.toString(), posY.toString());
  196. // ws.send(buffer);
  197. // isDrag = true;
  198. // }
  199. // }
  200. // myPlay.onmousemove = function (event) {
  201. // if (isDrag && event.button == 0) {
  202. // var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  203. // var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  204. // var buffer = ExexuteMouseMove(posX.toString(), posY.toString());
  205. // ws.send(buffer);
  206. // }
  207. // }
  208. // myPlay.onmouseup = function (event) {
  209. // isDrag = false;
  210. // var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  211. // var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  212. // var buffer = ExexuteMouseUp(posX.toString(), posY.toString());
  213. // ws.send(buffer);
  214. // }
  215. myPlay.onkeydown = function (event) {
  216. ExexuteKeyDown(e.keyCode);
  217. }
  218. }
  219. var ws;
  220. doConnect();
  221. function doConnect() {
  222. ws = new WebSocket(socketURL);
  223. ws.binaryType = 'arraybuffer';
  224. ws.onclose = function (e) {
  225. $.confirm({
  226. title: '提示',
  227. text: '连接断开,是否准备重连?',
  228. onOK: function () {
  229. doConnect();
  230. },
  231. onCancel: function () {
  232. wx.miniProgram.switchTab({
  233. url: '/pages/home/home'
  234. })
  235. }
  236. });
  237. }
  238. ws.addEventListener('open', function (event) {
  239. ws.send(ConfigChannel("RK3923C1201900139"));
  240. });
  241. ws.addEventListener('error', function (event) {
  242. $.confirm({
  243. title: '提示',
  244. text: '连接失败,是否准备重连?',
  245. onOK: function () {
  246. doConnect();
  247. },
  248. onCancel: function () {
  249. wx.miniProgram.switchTab({
  250. url: '/pages/home/home'
  251. })
  252. }
  253. });
  254. });
  255. ws.addEventListener('message', function (event) {
  256. var data = ParseProto(event.data); //JAVA服务器转发
  257. var input = new Uint8Array(event.data);
  258. if (data.audio != null && isAudioPlay) { //喂音频
  259. if (input[0] == 0xff) {
  260. if (isFinish) {
  261. decodeAAC(input);
  262. }
  263. }
  264. }
  265. if (data.video != null) { //喂视频
  266. if (isFeed) {
  267. jmuxer.feed(data);
  268. // $('.weui-mask_transparent').hide()
  269. // $('.weui-toast').hide()
  270. // $('.loading').hide()
  271. }
  272. }
  273. });
  274. }
  275. document.addEventListener("visibilitychange", function () {
  276. if (document.visibilityState == "visible") {
  277. var buffer = RequestIFrame();
  278. ws.send(buffer);
  279. isVisuable = true;
  280. } else {
  281. isVisuable = false;
  282. isFeed = false;
  283. myVideo.pause();
  284. }
  285. });
  286. myVideo.addEventListener('pause', function () {
  287. isFeed = false;
  288. });
  289. var decodeCount = 1;
  290. var player = new PCMPlayer({
  291. encoding: '16bitInt',
  292. channels: 2,
  293. sampleRate: 44100,
  294. flushingTime: 22,
  295. debug: false
  296. });
  297. function decodeAAC(data) {
  298. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  299. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  300. for (var i = 0; i < data.length; i++) {
  301. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  302. }
  303. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  304. if (pcmLen >= 0) {
  305. var pcmData = new Uint8Array(pcmLen);
  306. for (var i = 0; i < pcmLen; i++) {
  307. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  308. }
  309. player.feed(pcmData);
  310. }
  311. decodeCount++;
  312. Module._free(inputPtr);
  313. Module._free(retPtr);
  314. }
  315. //解协议
  316. function ParseProto(data) {
  317. var input = new Uint8Array(data),
  318. duration,
  319. video,
  320. audio;
  321. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  322. video = input;
  323. duration = 24;
  324. var nalType = input[4] & 0x1f;
  325. if (!isFeed) {
  326. if (nalType == 0x05 && isVisuable) {
  327. isFeed = true;
  328. }
  329. }
  330. } else if (input[0] == 0xff) {
  331. if (!isEnough) {
  332. requestCount++;
  333. }
  334. audio = input;
  335. if (new Date().getTime() - curTime > 100) {
  336. delayTime = new Date().getTime();
  337. }
  338. curTime = new Date().getTime();
  339. duration = 24;
  340. } else if (input[0] == 0x68) {
  341. if (input[23] == 0x05) { //横竖屏标识
  342. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  343. if (state == 1) {
  344. //竖屏处理
  345. console.log("安卓卡此时竖屏");
  346. } else {
  347. //横屏处理
  348. console.log("安卓卡此时横屏");
  349. }
  350. }
  351. if (input[23] == 0x0b) {
  352. console.log("多端登陆");
  353. }
  354. }
  355. return {
  356. audio: audio,
  357. video: video,
  358. duration: duration
  359. };
  360. }
  361. function GetRequest() {
  362. var url = location.search; // 获取url中"?"符后的字串
  363. var obj = new Object();
  364. if (url.indexOf("?") != -1) {
  365. var str = url.substr(1);
  366. strs = str.split("&");
  367. for (var i = 0; i < strs.length; i++) {
  368. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  369. }
  370. }
  371. return obj;
  372. }
  373. function Back() {
  374. ExexuteKeyDown(4);
  375. window.event.returnValue = false;
  376. return false;
  377. }
  378. var url = window.location.href;
  379. url = url.split('/');
  380. var baseUrl = "http://192.168.199.243";
  381. var form = {};
  382. $.ajax({
  383. url: baseUrl + "/api/user/v1/config/download/isShow",
  384. data: {},
  385. type: 'get',
  386. dataType: 'json',
  387. success: function (data) {
  388. if (data.data) {
  389. $("#showsuss").show()
  390. } else {
  391. $("#showsuss").hide()
  392. }
  393. }
  394. })
  395. form.clientType = parameters['clientType'];
  396. form.diskName = parameters['diskName'];
  397. if (form.clientType == 1) {
  398. form.cardIp = parameters['cardIp'];
  399. form.port = parameters['port'];
  400. form.sn = parameters['sn'];
  401. form.demoTime = parameters['demoTime'];
  402. form.id = parameters['id'];
  403. } else if (form.clientType == 2) { //分享屏幕
  404. $(".leftmains").css({
  405. "right": "-4rem"
  406. })
  407. $('.leftmains').hide()
  408. $('.bottommains').hide()
  409. $('#btnMuted').hide()
  410. form.id = parameters['id'];
  411. form.username = parameters['username'];
  412. form.ip = parameters['ip'];
  413. form.userCardId = parameters['userCardId'];
  414. } else {
  415. form.username = parameters['username'];
  416. form.userCardId = parameters['userCardId'];
  417. }
  418. var orientation = 0; //0 竖屏,1横屏
  419. document.body.addEventListener('touchmove', function (e) {
  420. e.preventDefault()
  421. }, {
  422. passive: false
  423. })
  424. // //初始化一下就可以了
  425. var vConsole = new VConsole();
  426. var btnMuted = document.querySelector("#btnMuted");
  427. btnMuted && (function () {
  428. var setHistory = function (left, top) {
  429. try {
  430. localStorage.setItem("muted-btn-loc", JSON.stringify({
  431. left: left,
  432. top: top
  433. }));
  434. } catch (ex) { }
  435. };
  436. var getHistory = function () {
  437. try {
  438. var value = localStorage.getItem("muted-btn-loc");
  439. if (!value) return null;
  440. value = JSON.parse(value);
  441. if (!value) return null;
  442. return value;
  443. } catch (ex) {
  444. return null
  445. }
  446. };
  447. var fixLoc = function (loc) {
  448. var rect = btnMuted.getBoundingClientRect();
  449. rect = {
  450. top: rect.top,
  451. left: rect.left,
  452. width: rect.width,
  453. height: rect.height
  454. }; //部分低版本浏览器,该属性为只读
  455. if (loc) {
  456. rect.left = loc.left;
  457. rect.top = loc.top;
  458. }
  459. var minX = 0;
  460. var minY = 0;
  461. var docRect = document.documentElement.getBoundingClientRect();
  462. var maxY = docRect.height - rect.height;
  463. var maxX = docRect.width - rect.width;
  464. var left = rect.left;
  465. var top = rect.top;
  466. left = Math.min(left, maxX);
  467. left = Math.max(left, minX);
  468. top = Math.min(top, maxY);
  469. top = Math.max(top, minY);
  470. if (loc || top !== rect.top || left !== rect.left) {
  471. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  472. }
  473. }
  474. window.addEventListener("resize", function () {
  475. fixLoc();
  476. });
  477. var touchPoint = {
  478. pageY: 0,
  479. pageX: 0
  480. };
  481. var currentLoc = {
  482. top: 0,
  483. left: 0,
  484. curTop: 0,
  485. curLeft: 0
  486. };
  487. var toMove = false;
  488. var touchmove = function (e) {
  489. e.preventDefault();
  490. var point = e.changedTouches[0];
  491. var top = -touchPoint.pageY + point.pageY;
  492. var left = -touchPoint.pageX + point.pageX;
  493. if (toMove) {
  494. top += currentLoc.top;
  495. left += currentLoc.left;
  496. currentLoc.curLeft = left;
  497. currentLoc.curTop = top;
  498. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  499. } else {
  500. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  501. toMove = true;
  502. }
  503. }
  504. };
  505. var touchend = function () {
  506. window.removeEventListener("touchmove", touchmove, {
  507. passive: false
  508. });
  509. window.removeEventListener("touchend", touchend, {
  510. passive: false
  511. });
  512. if (toMove) {
  513. setHistory(currentLoc.curLeft, currentLoc.curTop);
  514. fixLoc();
  515. } else {
  516. //按点击处理
  517. var set = $('.control-right-img').attr("data-id")
  518. if (set == '1') {
  519. $('.control-right-img').attr({
  520. "data-id": "2"
  521. })
  522. $(".leftmains").css({
  523. "right": "-4rem"
  524. })
  525. } else {
  526. $('.control-right-img').attr({
  527. "data-id": "1"
  528. })
  529. $(".leftmains").css({
  530. "right": "0rem"
  531. })
  532. }
  533. }
  534. }
  535. btnMuted.addEventListener("touchstart", function (e) {
  536. e.preventDefault();
  537. toMove = false;
  538. var point = e.changedTouches[0];
  539. touchPoint.pageX = point.pageX;
  540. touchPoint.pageY = point.pageY;
  541. var rect = e.target.getBoundingClientRect();
  542. currentLoc.top = rect.top;
  543. currentLoc.left = rect.left;
  544. window.addEventListener("touchmove", touchmove, {
  545. passive: false
  546. });
  547. window.addEventListener("touchend", touchend, {
  548. passive: false
  549. });
  550. }, {
  551. passive: false
  552. });
  553. var history = getHistory();
  554. if (history) {
  555. fixLoc(history);
  556. }
  557. btnMuted.classList.remove("hide");
  558. })();
  559. $(".boximg").on("click", function () {
  560. $(".mainbox").css({
  561. "display": "none"
  562. })
  563. })
  564. // 剪切板
  565. $(".sboxbu").on("click", function () {
  566. $(".sbox").css({
  567. "display": "none"
  568. })
  569. })
  570. // 剪切板
  571. $(".uploadss").on("click", function () {
  572. $(".sbox").css({
  573. "display": "none"
  574. })
  575. })
  576. $("#upload").on("click", function () {
  577. wx.miniProgram.switchTab({
  578. url: '/pages/home/home'
  579. })
  580. })
  581. function selectText(x) {
  582. if (document.selection) {
  583. var range = document.body.createTextRange();
  584. range.moveToElementText(x);
  585. range.select();
  586. } else if (window.getSelection) {
  587. var selection = window.getSelection();
  588. var range = document.createRange();
  589. selection.removeAllRanges();
  590. range.selectNodeContents(x);
  591. selection.addRange(range);
  592. }
  593. }
  594. function cp(x) {
  595. $(".mainbox").css({
  596. "display": "none"
  597. })
  598. $(".sbox").css({
  599. "display": "block"
  600. })
  601. selectText(x);
  602. document.execCommand("copy");
  603. }
  604. </script>
  605. <script type="text/javascript" src="aac.js"></script>
  606. </body>
  607. </html>