WXtrialInterface.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  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="viewport" content="initial-scale=1,maximum-scale=1, minimum-scale=1,user-scalable=no">
  8. <meta name="x5-orientation" content="portrait" />
  9. <meta name="screen-orientation" content="portrait" />
  10. <meta name="viewport" content="width=device-width, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
  11. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  12. <meta name="apple-mobile-web-app-capable" content="yes">
  13. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  14. <meta name="format-detection" content="telephone=no, email=no">
  15. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  16. <meta name="apple-mobile-web-app-capable" content="yes">
  17. <!-- 删除苹果默认的工具栏和菜单栏 -->
  18. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  19. <!-- 设置苹果工具栏颜��? -->
  20. <meta name="format-detection" content="telphone=no, email=no">
  21. <!-- 忽略页面中的数字识别为电话,忽略email识别 -->
  22. <!-- 启用360浏览器的极速模��?(webkit) -->
  23. <meta name="renderer" content="webkit">
  24. <!-- 避免IE使用兼容模式 -->
  25. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  26. <!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑��? -->
  27. <meta name="HandheldFriendly" content="true">
  28. <!-- 微软的老式浏览��? -->
  29. <meta name="MobileOptimized" content="320">
  30. <!-- uc强制竖屏 -->
  31. <!-- <meta name="screen-orientation" content="portrait"> -->
  32. <!-- QQ强制竖屏 -->
  33. <!-- <meta name="x5-orientation" content="portrait"> -->
  34. <!-- 不能旋转,问题出在这 -->
  35. <!-- UC强制全屏 -->
  36. <meta name="full-screen" content="yes">
  37. <!-- QQ强制全屏 -->
  38. <meta name="x5-fullscreen" content="true">
  39. <!-- UC应用模式 -->
  40. <meta name="browsermode" content="application">
  41. <!-- QQ应用模式 -->
  42. <meta name="x5-page-mode" content="app">
  43. <!-- windows phone 点击无高��? -->
  44. <meta name="msapplication-tap-highlight" content="no">
  45. <title></title>
  46. <link rel="stylesheet" type="text/css" href="css/WXtrialInterface.css" />
  47. <script async defer src="https://buttons.github.io/buttons.js"></script>
  48. </head>
  49. <body class="scroll h-player" style="overscroll-behavior: contain;">
  50. <div class="container" id="player">
  51. <div class="muted" id="btnMuted">
  52. <div class="control-right-img" data-id="1">
  53. <img src="../static/img/xuanfu_icon.png">
  54. </div>
  55. </div>
  56. <div id="wine">
  57. <!-- <video id="video1" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
  58. webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false" style="pointer-events: none;"></video> -->
  59. <!-- <div id="box"> -->
  60. <!-- <video muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true"
  61. webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5"
  62. x5-video-player-fullscreen="false" style="pointer-events: none;object-fit: fill;width: 100%;height:100%"
  63. disablePictureInPicture="true" poster="images/loader-thumb.jpg" id="playerVideo"></video> -->
  64. <video id="playerVideo" muted="muted" x5-video-orientation="landscape" playsinline="true" autoplay="true" webkit-playsinline="true" x5-playsinline="true" x5-video-player-type="h5" x5-video-player-fullscreen="false" style="pointer-events: none;object-fit: fill;width: 100%;height:100%"></video>
  65. <div id="box"></div>
  66. <audio preload="auto" autoplay controls poster="images/loader-thumb.jpg" id="audioPlayer"
  67. style="position: absolute;top: 0;width: 0;height: 0;"></audio>
  68. </div>
  69. <div class="leftmains">
  70. <div class="PictureQualityMain">
  71. <div class="PictureQuality " data-id="3072000">高清</div>
  72. <div class="PictureQuality avit" data-id="2243000">标清</div>
  73. <div class="PictureQuality" data-id="400000">极速</div>
  74. <div class="PictureQuality" data-id="400000">自动</div>
  75. </div>
  76. <div class="operation">
  77. <div class="upload" id="showsuss" data-text="uploads">
  78. <img src="../static/img/wx/shangchuan_icon.png">
  79. <div>上传</div>
  80. </div>
  81. <div class="upload" onclick="cp(document.getElementById('user_ref_id'));" data-text="Shearplate">
  82. <img src="../static/img/wx/jianqieban_icon.png">
  83. <div>剪切板</div>
  84. </div>
  85. <div class="upload" id="upload" data-text="Signout">
  86. <img src="../static/img/wx/tuichu_icon.png">
  87. <div>退出</div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="bottommains">
  92. <div class="botmat1">
  93. <div class="botmat1img" data-text="gengduo">
  94. <img src="../static/img/wx/gengduo_icon.png">
  95. </div>
  96. </div>
  97. <div class="botmat1">
  98. <div class="botmat1img" data-text="home">
  99. <img src="../static/img/wx/home_icon.png">
  100. </div>
  101. </div>
  102. <div class="botmat1">
  103. <div class="botmat1img" data-text="return">
  104. <img src="../static/img/wx/fanhui_icon.png">
  105. </div>
  106. </div>
  107. </div>
  108. <div class="mainbox" style="display: none;">
  109. <div class="boxTitle">提示</div>
  110. <div class="boxText">
  111. <div>由于小程序的功能限制,此功能暂时</div>
  112. <div>无法使用,请下载APP使用更多功能</div>
  113. </div>
  114. <div class="boxbt" onclick="cp(document.getElementById('user_ref_id'));">立即前往下载</div>
  115. <div class="boximg"><img src="../static/img/wx/guanbi_icon.png"></div>
  116. </div>
  117. <div class="sbox" style="display: none;">
  118. <div class="sboxText">下载地址已复制到剪切板</div>
  119. <div class="sboxbu">确定</div>
  120. </div>
  121. </div>
  122. <body oncontextmenu="Back()">
  123. </body>
  124. <div id="copy-txt" style="position: absolute;opacity: 0;">
  125. <span id="user_ref_id">www.androidsCloud.com</span>
  126. </div>
  127. <!-- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> -->
  128. <script src="../static/js/jquery-1.11.0.min.js"></script>
  129. <script src="helper.js"></script>
  130. <script type="text/javascript" src="pcm-player.js"></script>
  131. <!-- 音频
  132. <!-- <script src="../static/js/classlist.js"></script>
  133. <script src="../static/js/players.js"></script>
  134. <script src="../static/js/auroraplayer.js"></script>
  135. <script src="../static/js/aurora.js"></script>
  136. <script src="../static/js/aac.js"></script>
  137. <script src="../static/js/web.js?id=101"></script> -->
  138. <!-- <script src="../static/js/webapk.js"></script> -->
  139. <!-- 视频-->
  140. <!-- <script type="text/javascript" src="../static/js/Decoder.js"></script>
  141. <script type="text/javascript" src="../static/js/YUVCanvas.js"></script>
  142. <script type="text/javascript" src="../static/js/Player.js"></script> -->
  143. <!-- <script type="text/javascript" src="jmuxer.js"></script> -->
  144. <script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
  145. <script src="WXdraw.js?v=110"></script>
  146. <script>
  147. var topwinHeight = window.screen.height - window.innerHeight + 30; //计算title top 头部
  148. $('#wine').css({
  149. "width": window.screen.width,
  150. "height": window.screen.height - topwinHeight - 20,
  151. "position": "absolute",
  152. })
  153. var winese = document.createElement("wine");
  154. wine.style.top = "-" + winese + 'px';
  155. //隐藏控件 controls
  156. var fpsCount = 0;
  157. var requestCount = 0;
  158. var timeCount = 0;
  159. var isVisuable = true;
  160. var isFeed = true;
  161. var isDrag = false;
  162. var shoudDrop = false;
  163. var isEnough = true;
  164. var ifCanPlay = false;
  165. var isFinish = false;
  166. var delayTime = new Date().getTime();
  167. var feedTime = new Date().getTime();
  168. var readyTime = new Date().getTime();
  169. var requestTime = new Date().getTime();
  170. var curTime = new Date().getTime();
  171. var requestTime = new Date().getTime(); //记录离开时间
  172. var myVideo = document.getElementById("playerVideo");
  173. $("#wine").click(function() {
  174. console.log("9999999999")
  175. });
  176. var myAudio = document.getElementById("audioPlayer");
  177. var audioBuffer = [];
  178. var audioBack = [];
  179. Module = {};
  180. Module.onRuntimeInitialized = function() {
  181. console.log("Wasm 加载成功!")
  182. isFinish = true;
  183. }
  184. document.addEventListener("visibilitychange", () => {
  185. if (document.visibilityState == "visible") {
  186. console.log("页面可见,继续喂视频");
  187. //requestTime = new Date().getTime();
  188. isVisuable = true;
  189. } else {
  190. isVisuable = false;
  191. isFeed = false;
  192. myVideo.pause();
  193. }
  194. });
  195. myVideo.play();
  196. myVideo.addEventListener('pause', function() {
  197. //console.log("视频播放暂停");
  198. isFeed = false;
  199. });
  200. myAudio.addEventListener('canplay', function() {
  201. console.log("缓冲区大小 %f", myAudio.buffered.end(0) - myAudio.buffered.start(0));
  202. });
  203. var decodeCount = 1;
  204. var isFinish = false;
  205. var player = new PCMPlayer({
  206. encoding: '16bitInt',
  207. channels: 2,
  208. sampleRate: 44100,
  209. flushingTime: 22,
  210. debug: false
  211. });
  212. Module = {};
  213. Module.onRuntimeInitialized = function() {
  214. console.log("Wasm 加载成功!")
  215. isFinish = true;
  216. }
  217. function decodeAAC(data) {
  218. var retPtr = Module._malloc(4 * 5 * 1024); //接收的数据
  219. var inputPtr = Module._malloc(4 * data.length); //输入数据
  220. for (i = 0; i < data.length; i++) {
  221. Module.HEAPU8[(inputPtr) + i] = data[i]; //转换为堆数据
  222. }
  223. var pcmLen = Module._feedData(retPtr, inputPtr, data.length);
  224. if (pcmLen >= 0) {
  225. //console.log("%d帧 aac 解码成功, %d", decodeCount, pcmLen);
  226. var pcmData = new Uint8Array(pcmLen);
  227. for (i = 0; i < pcmLen; i++) {
  228. pcmData[i] = Module.HEAPU8[(retPtr) + i]
  229. }
  230. player.feed(pcmData);
  231. } else {
  232. console.log("%d帧 aac 解码失败, %d", decodeCount, pcmLen);
  233. }
  234. decodeCount++;
  235. Module._free(inputPtr);
  236. Module._free(retPtr);
  237. }
  238. //解协议
  239. function ParseProto(data) {
  240. var temp = "";
  241. var input = new Uint8Array(data),
  242. duration,
  243. video,
  244. audio;
  245. if (input[0] == 0 && input[1] == 0 && input[2] == 0 && input[3] == 1) {
  246. // debugger
  247. video = input;
  248. duration = 24;
  249. var nalType = input[4] & 0x1f; //nalType == 0x07|| nalType == 0x08 || nalType == 0x05
  250. if (!isFeed) {
  251. if (nalType == 0x05) {
  252. console.log("发现I帧");
  253. }
  254. if (nalType == 0x05 && isVisuable) {
  255. console.log("检测到I帧 %d,重新渲染, 耗时 %d ms", nalType, new Date().getTime() - requestTime);
  256. isFeed = true;
  257. }
  258. }
  259. } else if (input[0] == 0xff) {
  260. if (!isEnough) {
  261. requestCount++;
  262. //audioBuffer.push(input);
  263. }
  264. audio = input;
  265. if (new Date().getTime() - curTime > 100) {
  266. delayTime = new Date().getTime();
  267. console.log("接收时间 %d ms", new Date().getTime() - curTime);
  268. }
  269. curTime = new Date().getTime();
  270. duration = 24;
  271. //console.log("duration %d", duration);
  272. } else if (input[0] == 0x68) {
  273. if (input[23] == 0x05) //横竖屏标识
  274. {
  275. var state = CheckScreenDirection(input.slice(24, 24 + 8));
  276. if (state == 1) {
  277. console.log("安卓卡此时竖屏");
  278. //竖屏处理
  279. } else {
  280. console.log("安卓卡此时横屏");
  281. //横屏处理
  282. }
  283. }
  284. if (input[23] == 0x0b) {
  285. console.log("多端登陆");
  286. }
  287. //console.log("屏幕旋转 %s", PrintArry(input));
  288. }
  289. return {
  290. audio: audio,
  291. video: video,
  292. duration: duration
  293. };
  294. }
  295. window.onload = function() {
  296. // var socketURL = 'wss://jmuxer-demo-server.herokuapp.com';
  297. //socketURL = "ws://127.0.0.1:8080"
  298. // socketURL = "ws://192.168.11.233:8080"
  299. //socketURL = "ws://14.215.128.98:14112";
  300. // var socketURL = "ws://192.168.11.66:9101";
  301. // var socketURL = "ws://192.168.198.21:9101"
  302. var socketURL = "ws://14.215.128.97:15508"
  303. // socketURL = "ws://14.215.128.98:14077";
  304. //socketURL = "wss://192.168.11.242:9104";
  305. var jmuxer = new JMuxer({
  306. node: 'playerVideo',
  307. flushingTime: 15,
  308. fps: 30,
  309. mode: 'video',
  310. debug: false
  311. });
  312. var audioMuxer = new JMuxer({
  313. node: 'audioPlayer',
  314. flushingTime: 15,
  315. clearBuffer: true,
  316. fps: 60, //可以不选,原先43
  317. mode: 'audio',
  318. debug: false
  319. });
  320. curTime = new Date().getTime();
  321. var ws = new WebSocket(socketURL);
  322. ws.binaryType = 'arraybuffer';
  323. //断开检测
  324. ws.onclose = function(e) {
  325. alert("websocket连接断开");
  326. console.log('websocket 断开: ' + e.code + ' ' + e.reason + ' ' + e.wasClean);
  327. console.log(e);
  328. }
  329. ws.addEventListener('open', function(event) {
  330. console.log("发送配置帧");
  331. ws.send(ConfigChannel("RK3923C1201900139"));
  332. });
  333. ws.addEventListener('error', function(event) {
  334. console.log("连接失败");
  335. });
  336. ws.addEventListener('message', function(event) {
  337. var data = ParseProto(event.data); //JAVA服务器转发
  338. //console.log("收到数据");
  339. var audioData = {
  340. audio: data.audio,
  341. video: null,
  342. duration: data.duration
  343. };
  344. var videoData = {
  345. audio: null,
  346. video: data.video,
  347. duration: data.duration
  348. };
  349. var input = new Uint8Array(event.data);
  350. // console.log("音频数据", input, input[0] == 0xff);
  351. if (input[0] == 0xff) {
  352. if (isFinish) {
  353. var time = new Date().getTime();
  354. decodeAAC(input);
  355. }
  356. } else {}
  357. if (myAudio.readyState == 2) {
  358. requestTime = new Date().getTime();
  359. isEnough = false;
  360. console.log("数据存储不够,出现声音停止,时间差 %f", myAudio.buffered.end(0));
  361. myAudio.pause();
  362. //myAudio.playbackRate = 2;
  363. } else if (myAudio.readyState == 4 && isEnough == false) {
  364. myAudio.play();
  365. var time = new Date().getTime();
  366. isEnough = true;
  367. console.log("填满耗时 %d ms, 填充帧数 %d, 填充延迟 %d ms", time - requestTime, requestCount,
  368. requestCount * 23);
  369. console.log("----接收到启动 %d ms, 缓冲区 %f---", time - delayTime, myAudio.buffered.end(0) - myAudio
  370. .played.end(0));
  371. }
  372. if (data.audio != null) //喂音频
  373. {
  374. if (myAudio.buffered.length > 0 && myAudio.played.length > 0) {
  375. var bufferTime = myAudio.buffered.end(0) - myAudio.played.end(0);
  376. //console.log(" bufferTime %d", bufferTime);
  377. if (bufferTime > 1) {
  378. //console.log("丢掉一些包");
  379. //return;
  380. }
  381. }
  382. audioMuxer.feed(audioData);
  383. }
  384. if (data.video != null) //喂视频
  385. {
  386. if (isFeed) {
  387. // console.log("渲染视频");
  388. jmuxer.feed(data);
  389. }
  390. //jmuxer.feed(videoData);
  391. }
  392. });
  393. var myPlay = document.getElementById("wine");
  394. myPlay.onmousedown = function(event) {
  395. console.log('5555555555')
  396. if (event.button == 0) {
  397. var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  398. var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  399. var buffer = ExexuteMouseDown(posX.toString(), posY.toString());
  400. // console.log('posX=======posY', posX, posY)
  401. // console.log('buffer=======', buffer)
  402. ws.send(buffer);
  403. console.log('ws', ws)
  404. isDrag = true;
  405. }
  406. }
  407. myPlay.onmousemove = function(event) {
  408. console.log('5555555555', isDrag, event.button)
  409. if (isDrag && event.button == 0) {
  410. var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  411. var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  412. var buffer = ExexuteMouseMove(posX.toString(), posY.toString());
  413. ws.send(buffer);
  414. console.log("移动位置 %d, %d", posX, posY);
  415. }
  416. }
  417. myPlay.onmouseup = function(event) {
  418. console.log('5555555555')
  419. isDrag = false;
  420. var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  421. var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  422. var buffer = ExexuteMouseUp(posX.toString(), posY.toString());
  423. ws.send(buffer);
  424. }
  425. myPlay.onkeydown = function(event) {
  426. console.log('5555555555')
  427. ExexuteKeyDown(e.keyCode);
  428. }
  429. }
  430. function Back() {
  431. if (event.button == 2) {
  432. //ExexuteKeyDown(4);
  433. }
  434. ExexuteKeyDown(4);
  435. window.event.returnValue = false;
  436. return false;
  437. }
  438. var url = window.location.href;
  439. url = url.split('/')
  440. // var baseUrl = window.location.href; //"http://192.168.31.20"
  441. // var baseUrl = 'https://'+url[2] //url[2] //'http://192.168.31.159'//'http://' + url[2]
  442. var query = window.location.search.substring(1);
  443. // query = "clientType=1&cardIp=14.215.128.96&port=2012&sn=RK3930C2301900012&demoTime=3600&id=377&diskName=SC93mBww"
  444. var vars = query.split("&");
  445. console.log(vars)
  446. // var baseUrl = 'http://192.168.31.20'
  447. // var baseUrl = 'test.androidscloud.com'
  448. var baseUrl = "http://192.168.199.243";
  449. var data = {}
  450. // 审核
  451. $.ajax({
  452. url: baseUrl + "/api/user/v1/config/download/isShow",
  453. data: {},
  454. type: 'get',
  455. dataType: 'json',
  456. success: function(data) {
  457. if (data.data) {
  458. $("#showsuss").show()
  459. } else {
  460. $("#showsuss").hide()
  461. }
  462. //
  463. }
  464. })
  465. var clientType = vars.find(e => {
  466. return e.startsWith('clientType')
  467. }) || ''
  468. // console.log(clientType)
  469. data.clientType = clientType.substring(11, clientType.length)
  470. // 小程序直接进入
  471. var diskName = vars.find(e => {
  472. return e.startsWith('diskName')
  473. }) || ''
  474. data.diskName = diskName.substring(9, diskName.length)
  475. // document.title = decodeURI(data.diskName)
  476. if (data.clientType == 1) {
  477. var cardIp = vars.find(e => {
  478. return e.startsWith('cardIp')
  479. }) || ''
  480. var port = vars.find(e => {
  481. return e.startsWith('port')
  482. }) || ''
  483. var sn = vars.find(e => {
  484. return e.startsWith('sn')
  485. }) || ''
  486. var demoTime = vars.find(e => {
  487. return e.startsWith('demoTime')
  488. }) || ''
  489. var id = vars.find(e => {
  490. return e.startsWith('id')
  491. }) || ''
  492. data.clientType = clientType.substring(11, clientType.length)
  493. data.cardIp = cardIp.substring(7, cardIp.length)
  494. data.port = port.substring(5, port.length)
  495. data.sn = sn.substring(3, sn.length)
  496. data.demoTime = demoTime.substring(9, demoTime.length)
  497. data.id = id.substring(3, id.length)
  498. } else if (data.clientType == 2) { //分享屏幕
  499. console.log("走到分享屏幕里面啦==========", data.clientTypes);
  500. $(".leftmains").css({
  501. "right": "-4rem"
  502. })
  503. $('.leftmains').hide()
  504. $('.bottommains').hide()
  505. $('#btnMuted').hide()
  506. let ip = vars.find(e => {
  507. return e.startsWith('ip')
  508. }) || ''
  509. var username = vars.find(e => {
  510. return e.startsWith('username')
  511. }) || ''
  512. var id = vars.find(e => {
  513. return e.startsWith('id')
  514. }) || ''
  515. var userCardId = vars.find(e => {
  516. return e.startsWith('userCardId')
  517. }) || ''
  518. data.id = id.substring(3, id.length)
  519. data.username = username.substring(9, username.length)
  520. data.ip = ip.substring(3, ip.length)
  521. data.userCardId = userCardId.substring(11, userCardId.length)
  522. } else {
  523. // $(".leftmains").css({
  524. // "right":"-4rem"
  525. // })
  526. // $('.leftmains').hide()
  527. // $('.bottommains').hide()
  528. // $('#btnMuted').hide()
  529. var username = vars.find(e => {
  530. return e.startsWith('username')
  531. }) || ''
  532. var userCardId = vars.find(e => {
  533. return e.startsWith('userCardId')
  534. }) || ''
  535. data.username = username.substring(9, username.length)
  536. data.userCardId = userCardId.substring(11, userCardId.length)
  537. console.log(data.ip)
  538. }
  539. // 心跳
  540. // var time = 1000 * 30;
  541. // var interval;
  542. // fun()
  543. //
  544. // function run() {
  545. //
  546. // interval = setInterval(fun, time);
  547. // }
  548. //
  549. // function fun() {
  550. // $.ajax({
  551. // url: baseUrl + "/api/game/v1/cloudGame/dev/get/cardSn",
  552. // data: {
  553. // sn: data.sn
  554. // },
  555. // type: 'get',
  556. // dataType: 'json',
  557. // success: function(data) {
  558. //
  559. // }
  560. // })
  561. //
  562. // };
  563. // run();
  564. // data.clientType=1
  565. // data.sn="RK3930C2301900044"
  566. // data.cardIp="14.215.128.96"
  567. // data.port=2044
  568. var orientation = 0 //0 竖屏,1横屏
  569. var winHeight = window.screen.height - window.innerHeight
  570. // var urlss = url[2]
  571. // var urlss='192.168.31.20'
  572. // var urlss = "14.215.128.96"
  573. var urlss = 'test.androidscloud.com'
  574. document.body.addEventListener('touchmove', function(e) {
  575. e.preventDefault()
  576. }, {
  577. passive: false
  578. })
  579. //
  580. // urlss = "14.215.128.96"
  581. // console.log()
  582. // data.clientType = 1
  583. // data.sn="RK3930C2301900044"
  584. // data.cardIp="14.215.128.96"
  585. // data.port=2044
  586. // if (data.clientType == 3) {
  587. // var players = AV.Player.fromWebSocket("wss://" + urlss + '/authVideoWebSocket?' + "clientType=" + data.clientType +
  588. // "&username=" + data.username + "&userCardId=" + data.userCardId);
  589. // } else if (data.clientType == 2) {
  590. // // var players = AV.Player.fromWebSocket("wss://" + urlss + '/shareWebSocket?' + "clientType=" + data.clientType +
  591. // // "&username=" + data.username + "&userCardId=" + data.userCardId + "&ip=" + data.ip);
  592. // var players = AV.Player.fromWebSocket(
  593. // "wss://test.androidscloud.com/videoWebSocket?clientType=1&cardIp=14.215.128.96&port=2005&sn=RK3930C2301900005");
  594. // } else {
  595. // var players = AV.Player.fromWebSocket("wss://" + urlss + '/videoWebSocket?' + "clientType=" + data.clientType +
  596. // "&cardIp=" + data.cardIp + "&port=" + data.port + "&sn=" + data.sn);
  597. // }
  598. // // debugger
  599. // var players = AV.Player.fromWebSocket('ws://14.215.128.96/authVideoWebSocket?clientType=3&username=WqXTc1593762177&userCardId=377');
  600. // players.play();
  601. // players.volume = 100
  602. //var players = AV.Player.fromWebSocket('ws://14.215.128.96/videoWebSocket?clientType=0&cardIp=30.30.30.58&port=9100&sn=RK3930C2301900060');
  603. var warid = {
  604. id: data.id,
  605. type: 1,
  606. sn: data.sn
  607. }
  608. //结束时间 type=2
  609. var warids = {
  610. id: data.id,
  611. type: 2,
  612. sn: data.sn
  613. }
  614. // $.ajax({})
  615. // 关闭浏览器
  616. // window.onbeforeunload = function() {}
  617. //撤销的array
  618. var cancelList = new Array();
  619. //撤销的次数
  620. var cancelIndex = 0;
  621. var inputType = 0 //输入类型 0:手写,1:键盘输入
  622. //判断是否ie
  623. var IE_HACK = (/msie/i.test(navigator.userAgent) &&
  624. !/opera/i.test(navigator.userAgent));
  625. // 云手机相关逻辑
  626. // var player = new Player({
  627. // size: {
  628. // width: 1280,
  629. // height: 720
  630. // }
  631. // });
  632. // var secanv = document.getElementById("wine");
  633. // secanv.appendChild(player.canvas);
  634. // console.log("player=========>>>>", player);
  635. // console.log("secanv>>>>", secanv);
  636. // &cardIp="+data.data.extranetIp+"&port="+data.data.extranetPort+"&sn="+data.data.sn
  637. $(function() {
  638. initCanvas();
  639. });
  640. //初始化
  641. var initCanvas = function() {
  642. }
  643. $("#voew").on("click", function() {})
  644. $("#box").on("click", function() {
  645. // draw_graph('pencil', this)
  646. })
  647. console.log(player)
  648. $('#mocan').on('click', function() {
  649. draw_graph('pencil', this)
  650. })
  651. // //初始化一下就可以了,
  652. let vConsole = new VConsole();
  653. // //你打印的数据 比如
  654. console.log('test');
  655. //就可像小程序一样的看了和调试了。
  656. $('.no-ne-an').on('click', function() {
  657. //结束时间 type=2
  658. let warids = {
  659. id: data.id,
  660. type: 2,
  661. sn: data.sn
  662. }
  663. $.ajax({
  664. url: baseUrl + "/api/game/v1/cloudGame/dev/getSn",
  665. data: warid,
  666. type: 'get',
  667. dataType: 'json',
  668. success: function(data) {
  669. history.go(-1)
  670. if (data.status == 0) {
  671. } else {
  672. alert(data.msg)
  673. }
  674. //
  675. }
  676. })
  677. })
  678. var btnMuted = document.querySelector("#btnMuted");
  679. btnMuted && (function() {
  680. var setHistory = function(left, top) {
  681. try {
  682. localStorage.setItem("muted-btn-loc", JSON.stringify({
  683. left: left,
  684. top: top
  685. }));
  686. } catch (ex) {}
  687. };
  688. var getHistory = function() {
  689. try {
  690. var value = localStorage.getItem("muted-btn-loc");
  691. if (!value) return null;
  692. value = JSON.parse(value);
  693. if (!value) return null;
  694. return value;
  695. } catch (ex) {
  696. return null
  697. }
  698. };
  699. var fixLoc = function(loc) {
  700. var rect = btnMuted.getBoundingClientRect();
  701. rect = {
  702. top: rect.top,
  703. left: rect.left,
  704. width: rect.width,
  705. height: rect.height
  706. }; //部分低版本浏览器,该属性为只读
  707. if (loc) {
  708. rect.left = loc.left;
  709. rect.top = loc.top;
  710. }
  711. var minX = 0;
  712. var minY = 0;
  713. var docRect = document.documentElement.getBoundingClientRect();
  714. var maxY = docRect.height - rect.height;
  715. var maxX = docRect.width - rect.width;
  716. var left = rect.left;
  717. var top = rect.top;
  718. left = Math.min(left, maxX);
  719. left = Math.max(left, minX);
  720. top = Math.min(top, maxY);
  721. top = Math.max(top, minY);
  722. console.log(rect.top, top, loc);
  723. if (loc || top !== rect.top || left !== rect.left) {
  724. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  725. }
  726. }
  727. window.addEventListener("resize", function() {
  728. fixLoc();
  729. });
  730. var touchPoint = {
  731. pageY: 0,
  732. pageX: 0
  733. };
  734. var currentLoc = {
  735. top: 0,
  736. left: 0,
  737. curTop: 0,
  738. curLeft: 0
  739. };
  740. var toMove = false;
  741. var touchmove = function(e) {
  742. e.preventDefault();
  743. var point = e.changedTouches[0];
  744. var top = -touchPoint.pageY + point.pageY;
  745. var left = -touchPoint.pageX + point.pageX;
  746. if (toMove) {
  747. top += currentLoc.top;
  748. left += currentLoc.left;
  749. currentLoc.curLeft = left;
  750. currentLoc.curTop = top;
  751. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  752. } else {
  753. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  754. toMove = true;
  755. }
  756. }
  757. };
  758. var touchend = function() {
  759. window.removeEventListener("touchmove", touchmove, {
  760. passive: false
  761. });
  762. window.removeEventListener("touchend", touchend, {
  763. passive: false
  764. });
  765. if (toMove) {
  766. setHistory(currentLoc.curLeft, currentLoc.curTop);
  767. fixLoc();
  768. } else {
  769. //按点击处理
  770. var set = $('.control-right-img').attr("data-id")
  771. if (set == '1') {
  772. $('.control-right-img').attr({
  773. "data-id": "2"
  774. })
  775. // $('.control-right-img').find('img').attr({
  776. // "src": "../static/img/musicturn.png"
  777. // })
  778. // players.volume = 100
  779. $(".leftmains").css({
  780. "right": "-4rem"
  781. })
  782. // console.log(players)
  783. // players.play();
  784. } else {
  785. $('.control-right-img').attr({
  786. "data-id": "1"
  787. })
  788. $(".leftmains").css({
  789. "right": "0rem"
  790. })
  791. // $('.control-right-img').find('img').attr({
  792. // "src": "../static/img/musicfalse.png"
  793. // })
  794. // players.volume = 0
  795. // players.off('pause');
  796. // players.pause();
  797. // var embed = document.embedPlay;
  798. // console.log(players, "fdsfdsf")
  799. }
  800. }
  801. }
  802. btnMuted.addEventListener("touchstart", function(e) {
  803. e.preventDefault();
  804. toMove = false;
  805. var point = e.changedTouches[0];
  806. touchPoint.pageX = point.pageX;
  807. touchPoint.pageY = point.pageY;
  808. var rect = e.target.getBoundingClientRect();
  809. currentLoc.top = rect.top;
  810. currentLoc.left = rect.left;
  811. window.addEventListener("touchmove", touchmove, {
  812. passive: false
  813. });
  814. window.addEventListener("touchend", touchend, {
  815. passive: false
  816. });
  817. }, {
  818. passive: false
  819. });
  820. var history = getHistory();
  821. if (history) {
  822. fixLoc(history);
  823. }
  824. btnMuted.classList.remove("hide");
  825. })();
  826. $(".boximg").on("click", function() {
  827. $(".mainbox").css({
  828. "display": "none"
  829. })
  830. })
  831. // 剪切板
  832. $(".sboxbu").on("click", function() {
  833. $(".sbox").css({
  834. "display": "none"
  835. })
  836. })
  837. // 剪切板
  838. $(".uploadss").on("click", function() {
  839. $(".sbox").css({
  840. "display": "none"
  841. })
  842. })
  843. $("#upload").on("click", function() {
  844. wx.miniProgram.switchTab({
  845. url: '/pages/home/home'
  846. })
  847. })
  848. function selectText(x) {
  849. if (document.selection) {
  850. var range = document.body.createTextRange();
  851. range.moveToElementText(x);
  852. range.select();
  853. } else if (window.getSelection) {
  854. var selection = window.getSelection();
  855. var range = document.createRange();
  856. selection.removeAllRanges();
  857. range.selectNodeContents(x);
  858. selection.addRange(range);
  859. }
  860. }
  861. function cp(x) {
  862. $(".mainbox").css({
  863. "display": "none"
  864. })
  865. $(".sbox").css({
  866. "display": "block"
  867. })
  868. selectText(x);
  869. document.execCommand("copy");
  870. }
  871. </script>
  872. <script type="text/javascript" src="jmuxer.js"></script>
  873. <script type="text/text/javascript" src="aac.js"></script>
  874. </body>
  875. </html>