WXtrialInterface.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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 src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
  122. <script type="text/javascript" src="WXdraw.js?v=110"></script>
  123. <script type="text/javascript" src="jmuxer.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. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  139. $('#wine').css({
  140. "width": window.screen.width,
  141. "height": window.screen.height - topwinHeight - 20,
  142. "position": "absolute"
  143. });
  144. $('.loading').css({
  145. "width": window.screen.width,
  146. "height": window.screen.height - topwinHeight - 20
  147. });
  148. var winese = document.createElement("wine");
  149. wine.style.top = "-" + winese + 'px';
  150. var requestCount = 0;
  151. var isVisuable = true;
  152. var isFeed = true;
  153. var isDrag = false;
  154. var isEnough = true;
  155. var isFinish = false;
  156. var delayTime = new Date().getTime();
  157. var curTime = new Date().getTime();
  158. var myVideo = document.getElementById("playerVideo");
  159. Module = {};
  160. Module.onRuntimeInitialized = function () {
  161. isFinish = true;
  162. }
  163. var isWSS = false;
  164. var parameters = GetRequest();
  165. var ip = parameters["ip"];
  166. var domainName = parameters["domainName"];
  167. var socketURL = isWSS ? "wss://" + form.domainName + "/card?cardIp=" + form.ip : "ws://" + domainName + "/card?cardIp=" + ip;
  168. var jmuxer = new JMuxer({
  169. node: 'playerVideo',
  170. flushingTime: 15,
  171. fps: 30,
  172. mode: 'video',
  173. debug: false
  174. });
  175. window.onload = function () {
  176. curTime = new Date().getTime();
  177. var myPlay = document.getElementById("wine");
  178. myPlay.onkeydown = function (event) {
  179. ExexuteKeyDown(e.keyCode);
  180. }
  181. }
  182. var ws;
  183. doConnect();
  184. function doConnect() {
  185. ws = new WebSocket(socketURL);
  186. ws.binaryType = 'arraybuffer';
  187. ws.onclose = function (e) {
  188. ws.close();
  189. doConnect();
  190. }
  191. ws.addEventListener('open', function (event) {
  192. ws.send(ConfigChannel("RK3923C1201900139"));
  193. });
  194. ws.addEventListener('error', function (event) {
  195. console.log(event);
  196. ws.close();
  197. doConnect();
  198. });
  199. ws.addEventListener('message', function (event) {
  200. var data = ParseProto(event.data); //JAVA服务器转发
  201. var input = new Uint8Array(event.data);
  202. if (data.audio != null && isAudioPlay) { //喂音频
  203. if (input[0] == 0xff) {
  204. if (isFinish) {
  205. decodeAAC(input);
  206. }
  207. }
  208. }
  209. if (data.video != null) { //喂视频
  210. if (isFeed) {
  211. jmuxer.feed(data);
  212. }
  213. }
  214. });
  215. }
  216. document.addEventListener("visibilitychange", function () {
  217. if (document.visibilityState == "visible") {
  218. var buffer = RequestIFrame();
  219. ws.send(buffer);
  220. isVisuable = true;
  221. } else {
  222. isVisuable = false;
  223. isFeed = false;
  224. myVideo.pause();
  225. }
  226. });
  227. myVideo.addEventListener('pause', function () {
  228. isFeed = false;
  229. });
  230. var decodeCount = 1;
  231. var player = new PCMPlayer({
  232. encoding: '16bitInt',
  233. channels: 2,
  234. sampleRate: 44100,
  235. flushingTime: 22,
  236. debug: false
  237. });
  238. function decodeAAC(data) {
  239. var retPtr = Module._malloc(4 * 5 * 1024); // 接收的数据
  240. var inputPtr = Module._malloc(4 * data.length); // 输入数据
  241. for (var i = 0; i < data.length; i++) {
  242. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  243. }
  244. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  245. if (pcmLen >= 0) {
  246. var pcmData = new Uint8Array(pcmLen);
  247. for (var i = 0; i < pcmLen; i++) {
  248. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  249. }
  250. player.feed(pcmData);
  251. }
  252. decodeCount++;
  253. Module._free(inputPtr);
  254. Module._free(retPtr);
  255. }
  256. //解协议
  257. function ParseProto(data) {
  258. var input = new Uint8Array(data),
  259. duration,
  260. video,
  261. audio;
  262. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  263. video = input;
  264. duration = 24;
  265. var nalType = input[4] & 0x1f;
  266. if (!isFeed) {
  267. if (nalType == 0x05 && isVisuable) {
  268. isFeed = true;
  269. }
  270. }
  271. } else if (input[0] == 0xff) {
  272. if (!isEnough) {
  273. requestCount++;
  274. }
  275. audio = input;
  276. if (new Date().getTime() - curTime > 100) {
  277. delayTime = new Date().getTime();
  278. }
  279. curTime = new Date().getTime();
  280. duration = 24;
  281. } else if (input[0] == 0x68) {
  282. if (input[23] == 0x05) { //横竖屏标识
  283. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  284. if (state == 1) {
  285. //竖屏处理
  286. console.log("安卓卡此时竖屏");
  287. } else {
  288. //横屏处理
  289. console.log("安卓卡此时横屏");
  290. }
  291. }
  292. if (input[23] == 0x0b) {
  293. console.log("多端登陆");
  294. }
  295. }
  296. return {
  297. audio: audio,
  298. video: video,
  299. duration: duration
  300. };
  301. }
  302. function GetRequest() {
  303. var url = location.search; // 获取url中"?"符后的字串
  304. var obj = new Object();
  305. if (url.indexOf("?") != -1) {
  306. var str = url.substr(1);
  307. strs = str.split("&");
  308. for (var i = 0; i < strs.length; i++) {
  309. obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
  310. }
  311. }
  312. return obj;
  313. }
  314. function Back() {
  315. ExexuteKeyDown(4);
  316. window.event.returnValue = false;
  317. return false;
  318. }
  319. var url = window.location.href;
  320. url = url.split('/');
  321. var baseUrl = "http://192.168.199.243";
  322. var form = {};
  323. $.ajax({
  324. url: baseUrl + "/api/user/v1/config/download/isShow",
  325. data: {},
  326. type: 'get',
  327. dataType: 'json',
  328. success: function (data) {
  329. if (data.data) {
  330. $("#showsuss").show()
  331. } else {
  332. $("#showsuss").hide()
  333. }
  334. }
  335. })
  336. form.clientType = parameters['clientType'];
  337. form.diskName = parameters['diskName'];
  338. if (form.clientType == 1) {
  339. form.cardIp = parameters['cardIp'];
  340. form.port = parameters['port'];
  341. form.sn = parameters['sn'];
  342. form.demoTime = parameters['demoTime'];
  343. form.id = parameters['id'];
  344. } else if (form.clientType == 2) { //分享屏幕
  345. $(".leftmains").css({
  346. "right": "-4rem"
  347. })
  348. $('.leftmains').hide()
  349. $('.bottommains').hide()
  350. $('#btnMuted').hide()
  351. form.id = parameters['id'];
  352. form.username = parameters['username'];
  353. form.ip = parameters['ip'];
  354. form.userCardId = parameters['userCardId'];
  355. } else {
  356. form.username = parameters['username'];
  357. form.userCardId = parameters['userCardId'];
  358. }
  359. var orientation = 0; //0 竖屏,1横屏
  360. document.body.addEventListener('touchmove', function (e) {
  361. e.preventDefault()
  362. }, {
  363. passive: false
  364. })
  365. // //初始化一下就可以了
  366. var vConsole = new VConsole();
  367. var btnMuted = document.querySelector("#btnMuted");
  368. btnMuted && (function () {
  369. var setHistory = function (left, top) {
  370. try {
  371. localStorage.setItem("muted-btn-loc", JSON.stringify({
  372. left: left,
  373. top: top
  374. }));
  375. } catch (ex) { }
  376. };
  377. var getHistory = function () {
  378. try {
  379. var value = localStorage.getItem("muted-btn-loc");
  380. if (!value) return null;
  381. value = JSON.parse(value);
  382. if (!value) return null;
  383. return value;
  384. } catch (ex) {
  385. return null
  386. }
  387. };
  388. var fixLoc = function (loc) {
  389. var rect = btnMuted.getBoundingClientRect();
  390. rect = {
  391. top: rect.top,
  392. left: rect.left,
  393. width: rect.width,
  394. height: rect.height
  395. }; //部分低版本浏览器,该属性为只读
  396. if (loc) {
  397. rect.left = loc.left;
  398. rect.top = loc.top;
  399. }
  400. var minX = 0;
  401. var minY = 0;
  402. var docRect = document.documentElement.getBoundingClientRect();
  403. var maxY = docRect.height - rect.height;
  404. var maxX = docRect.width - rect.width;
  405. var left = rect.left;
  406. var top = rect.top;
  407. left = Math.min(left, maxX);
  408. left = Math.max(left, minX);
  409. top = Math.min(top, maxY);
  410. top = Math.max(top, minY);
  411. if (loc || top !== rect.top || left !== rect.left) {
  412. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  413. }
  414. }
  415. window.addEventListener("resize", function () {
  416. fixLoc();
  417. });
  418. var touchPoint = {
  419. pageY: 0,
  420. pageX: 0
  421. };
  422. var currentLoc = {
  423. top: 0,
  424. left: 0,
  425. curTop: 0,
  426. curLeft: 0
  427. };
  428. var toMove = false;
  429. var touchmove = function (e) {
  430. e.preventDefault();
  431. var point = e.changedTouches[0];
  432. var top = -touchPoint.pageY + point.pageY;
  433. var left = -touchPoint.pageX + point.pageX;
  434. if (toMove) {
  435. top += currentLoc.top;
  436. left += currentLoc.left;
  437. currentLoc.curLeft = left;
  438. currentLoc.curTop = top;
  439. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  440. } else {
  441. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  442. toMove = true;
  443. }
  444. }
  445. };
  446. var touchend = function () {
  447. window.removeEventListener("touchmove", touchmove, {
  448. passive: false
  449. });
  450. window.removeEventListener("touchend", touchend, {
  451. passive: false
  452. });
  453. if (toMove) {
  454. setHistory(currentLoc.curLeft, currentLoc.curTop);
  455. fixLoc();
  456. } else {
  457. //按点击处理
  458. var set = $('.control-right-img').attr("data-id")
  459. if (set == '1') {
  460. $('.control-right-img').attr({
  461. "data-id": "2"
  462. })
  463. $(".leftmains").css({
  464. "right": "-4rem"
  465. })
  466. } else {
  467. $('.control-right-img').attr({
  468. "data-id": "1"
  469. })
  470. $(".leftmains").css({
  471. "right": "0rem"
  472. })
  473. }
  474. }
  475. }
  476. btnMuted.addEventListener("touchstart", function (e) {
  477. e.preventDefault();
  478. toMove = false;
  479. var point = e.changedTouches[0];
  480. touchPoint.pageX = point.pageX;
  481. touchPoint.pageY = point.pageY;
  482. var rect = e.target.getBoundingClientRect();
  483. currentLoc.top = rect.top;
  484. currentLoc.left = rect.left;
  485. window.addEventListener("touchmove", touchmove, {
  486. passive: false
  487. });
  488. window.addEventListener("touchend", touchend, {
  489. passive: false
  490. });
  491. }, {
  492. passive: false
  493. });
  494. var history = getHistory();
  495. if (history) {
  496. fixLoc(history);
  497. }
  498. btnMuted.classList.remove("hide");
  499. })();
  500. $(".boximg").on("click", function () {
  501. $(".mainbox").css({
  502. "display": "none"
  503. })
  504. })
  505. // 剪切板
  506. $(".sboxbu").on("click", function () {
  507. $(".sbox").css({
  508. "display": "none"
  509. })
  510. })
  511. // 剪切板
  512. $(".uploadss").on("click", function () {
  513. $(".sbox").css({
  514. "display": "none"
  515. })
  516. })
  517. $("#upload").on("click", function () {
  518. wx.miniProgram.switchTab({
  519. url: '/pages/home/home'
  520. })
  521. })
  522. function selectText(x) {
  523. if (document.selection) {
  524. var range = document.body.createTextRange();
  525. range.moveToElementText(x);
  526. range.select();
  527. } else if (window.getSelection) {
  528. var selection = window.getSelection();
  529. var range = document.createRange();
  530. selection.removeAllRanges();
  531. range.selectNodeContents(x);
  532. selection.addRange(range);
  533. }
  534. }
  535. function cp(x) {
  536. $(".mainbox").css({
  537. "display": "none"
  538. })
  539. $(".sbox").css({
  540. "display": "block"
  541. })
  542. selectText(x);
  543. document.execCommand("copy");
  544. }
  545. </script>
  546. <script type="text/javascript" src="aac.js"></script>
  547. </body>
  548. </html>