WXtrialInterface.html 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  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. var socketURL = "ws://192.168.198.82:9100"
  304. // socketURL = "ws://14.215.128.98:14077";
  305. //socketURL = "wss://192.168.11.242:9104";
  306. var jmuxer = new JMuxer({
  307. node: 'playerVideo',
  308. flushingTime: 15,
  309. fps: 30,
  310. mode: 'video',
  311. debug: false
  312. });
  313. var audioMuxer = new JMuxer({
  314. node: 'audioPlayer',
  315. flushingTime: 15,
  316. clearBuffer: true,
  317. fps: 60, //可以不选,原先43
  318. mode: 'audio',
  319. debug: false
  320. });
  321. curTime = new Date().getTime();
  322. var ws = new WebSocket(socketURL);
  323. ws.binaryType = 'arraybuffer';
  324. //断开检测
  325. ws.onclose = function(e) {
  326. alert("websocket连接断开");
  327. console.log('websocket 断开: ' + e.code + ' ' + e.reason + ' ' + e.wasClean);
  328. console.log(e);
  329. }
  330. ws.addEventListener('open', function(event) {
  331. console.log("发送配置帧");
  332. ws.send(ConfigChannel("RK3923C1201900139"));
  333. });
  334. ws.addEventListener('error', function(event) {
  335. console.log("连接失败");
  336. });
  337. ws.addEventListener('message', function(event) {
  338. var data = ParseProto(event.data); //JAVA服务器转发
  339. //console.log("收到数据");
  340. var audioData = {
  341. audio: data.audio,
  342. video: null,
  343. duration: data.duration
  344. };
  345. var videoData = {
  346. audio: null,
  347. video: data.video,
  348. duration: data.duration
  349. };
  350. var input = new Uint8Array(event.data);
  351. // console.log("音频数据", input, input[0] == 0xff);
  352. if (input[0] == 0xff) {
  353. if (isFinish) {
  354. var time = new Date().getTime();
  355. decodeAAC(input);
  356. }
  357. } else {}
  358. if (myAudio.readyState == 2) {
  359. requestTime = new Date().getTime();
  360. isEnough = false;
  361. console.log("数据存储不够,出现声音停止,时间差 %f", myAudio.buffered.end(0));
  362. myAudio.pause();
  363. //myAudio.playbackRate = 2;
  364. } else if (myAudio.readyState == 4 && isEnough == false) {
  365. myAudio.play();
  366. var time = new Date().getTime();
  367. isEnough = true;
  368. console.log("填满耗时 %d ms, 填充帧数 %d, 填充延迟 %d ms", time - requestTime, requestCount,
  369. requestCount * 23);
  370. console.log("----接收到启动 %d ms, 缓冲区 %f---", time - delayTime, myAudio.buffered.end(0) - myAudio
  371. .played.end(0));
  372. }
  373. if (data.audio != null) //喂音频
  374. {
  375. if (myAudio.buffered.length > 0 && myAudio.played.length > 0) {
  376. var bufferTime = myAudio.buffered.end(0) - myAudio.played.end(0);
  377. //console.log(" bufferTime %d", bufferTime);
  378. if (bufferTime > 1) {
  379. //console.log("丢掉一些包");
  380. //return;
  381. }
  382. }
  383. audioMuxer.feed(audioData);
  384. }
  385. if (data.video != null) //喂视频
  386. {
  387. if (isFeed) {
  388. // console.log("渲染视频");
  389. jmuxer.feed(data);
  390. }
  391. //jmuxer.feed(videoData);
  392. }
  393. });
  394. var myPlay = document.getElementById("wine");
  395. myPlay.onmousedown = function(event) {
  396. console.log('5555555555')
  397. if (event.button == 0) {
  398. var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  399. var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  400. var buffer = ExexuteMouseDown(posX.toString(), posY.toString());
  401. // console.log('posX=======posY', posX, posY)
  402. // console.log('buffer=======', buffer)
  403. ws.send(buffer);
  404. console.log('ws', ws)
  405. isDrag = true;
  406. }
  407. }
  408. myPlay.onmousemove = function(event) {
  409. console.log('5555555555', isDrag, event.button)
  410. if (isDrag && event.button == 0) {
  411. var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  412. var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  413. var buffer = ExexuteMouseMove(posX.toString(), posY.toString());
  414. ws.send(buffer);
  415. console.log("移动位置 %d, %d", posX, posY);
  416. }
  417. }
  418. myPlay.onmouseup = function(event) {
  419. console.log('5555555555')
  420. isDrag = false;
  421. var posX = event.offsetX * 720 * 1.0 / myVideo.clientWidth;
  422. var posY = event.offsetY * 1280 * 1.0 / myVideo.clientHeight;
  423. var buffer = ExexuteMouseUp(posX.toString(), posY.toString());
  424. ws.send(buffer);
  425. }
  426. myPlay.onkeydown = function(event) {
  427. console.log('5555555555')
  428. ExexuteKeyDown(e.keyCode);
  429. }
  430. }
  431. function Back() {
  432. if (event.button == 2) {
  433. //ExexuteKeyDown(4);
  434. }
  435. ExexuteKeyDown(4);
  436. window.event.returnValue = false;
  437. return false;
  438. }
  439. var url = window.location.href;
  440. url = url.split('/')
  441. // var baseUrl = window.location.href; //"http://192.168.31.20"
  442. // var baseUrl = 'https://'+url[2] //url[2] //'http://192.168.31.159'//'http://' + url[2]
  443. var query = window.location.search.substring(1);
  444. // query = "clientType=1&cardIp=14.215.128.96&port=2012&sn=RK3930C2301900012&demoTime=3600&id=377&diskName=SC93mBww"
  445. var vars = query.split("&");
  446. console.log(vars)
  447. // var baseUrl = 'http://192.168.31.20'
  448. // var baseUrl = 'test.androidscloud.com'
  449. var baseUrl = "http://192.168.199.243";
  450. var data = {}
  451. // 审核
  452. $.ajax({
  453. url: baseUrl + "/api/user/v1/config/download/isShow",
  454. data: {},
  455. type: 'get',
  456. dataType: 'json',
  457. success: function(data) {
  458. if (data.data) {
  459. $("#showsuss").show()
  460. } else {
  461. $("#showsuss").hide()
  462. }
  463. //
  464. }
  465. })
  466. var clientType = vars.find(e => {
  467. return e.startsWith('clientType')
  468. }) || ''
  469. // console.log(clientType)
  470. data.clientType = clientType.substring(11, clientType.length)
  471. // 小程序直接进入
  472. var diskName = vars.find(e => {
  473. return e.startsWith('diskName')
  474. }) || ''
  475. data.diskName = diskName.substring(9, diskName.length)
  476. // document.title = decodeURI(data.diskName)
  477. if (data.clientType == 1) {
  478. var cardIp = vars.find(e => {
  479. return e.startsWith('cardIp')
  480. }) || ''
  481. var port = vars.find(e => {
  482. return e.startsWith('port')
  483. }) || ''
  484. var sn = vars.find(e => {
  485. return e.startsWith('sn')
  486. }) || ''
  487. var demoTime = vars.find(e => {
  488. return e.startsWith('demoTime')
  489. }) || ''
  490. var id = vars.find(e => {
  491. return e.startsWith('id')
  492. }) || ''
  493. data.clientType = clientType.substring(11, clientType.length)
  494. data.cardIp = cardIp.substring(7, cardIp.length)
  495. data.port = port.substring(5, port.length)
  496. data.sn = sn.substring(3, sn.length)
  497. data.demoTime = demoTime.substring(9, demoTime.length)
  498. data.id = id.substring(3, id.length)
  499. } else if (data.clientType == 2) { //分享屏幕
  500. console.log("走到分享屏幕里面啦==========", data.clientTypes);
  501. $(".leftmains").css({
  502. "right": "-4rem"
  503. })
  504. $('.leftmains').hide()
  505. $('.bottommains').hide()
  506. $('#btnMuted').hide()
  507. let ip = vars.find(e => {
  508. return e.startsWith('ip')
  509. }) || ''
  510. var username = vars.find(e => {
  511. return e.startsWith('username')
  512. }) || ''
  513. var id = vars.find(e => {
  514. return e.startsWith('id')
  515. }) || ''
  516. var userCardId = vars.find(e => {
  517. return e.startsWith('userCardId')
  518. }) || ''
  519. data.id = id.substring(3, id.length)
  520. data.username = username.substring(9, username.length)
  521. data.ip = ip.substring(3, ip.length)
  522. data.userCardId = userCardId.substring(11, userCardId.length)
  523. } else {
  524. // $(".leftmains").css({
  525. // "right":"-4rem"
  526. // })
  527. // $('.leftmains').hide()
  528. // $('.bottommains').hide()
  529. // $('#btnMuted').hide()
  530. var username = vars.find(e => {
  531. return e.startsWith('username')
  532. }) || ''
  533. var userCardId = vars.find(e => {
  534. return e.startsWith('userCardId')
  535. }) || ''
  536. data.username = username.substring(9, username.length)
  537. data.userCardId = userCardId.substring(11, userCardId.length)
  538. console.log(data.ip)
  539. }
  540. // 心跳
  541. // var time = 1000 * 30;
  542. // var interval;
  543. // fun()
  544. //
  545. // function run() {
  546. //
  547. // interval = setInterval(fun, time);
  548. // }
  549. //
  550. // function fun() {
  551. // $.ajax({
  552. // url: baseUrl + "/api/game/v1/cloudGame/dev/get/cardSn",
  553. // data: {
  554. // sn: data.sn
  555. // },
  556. // type: 'get',
  557. // dataType: 'json',
  558. // success: function(data) {
  559. //
  560. // }
  561. // })
  562. //
  563. // };
  564. // run();
  565. // data.clientType=1
  566. // data.sn="RK3930C2301900044"
  567. // data.cardIp="14.215.128.96"
  568. // data.port=2044
  569. var orientation = 0 //0 竖屏,1横屏
  570. var winHeight = window.screen.height - window.innerHeight
  571. // var urlss = url[2]
  572. // var urlss='192.168.31.20'
  573. // var urlss = "14.215.128.96"
  574. var urlss = 'test.androidscloud.com'
  575. document.body.addEventListener('touchmove', function(e) {
  576. e.preventDefault()
  577. }, {
  578. passive: false
  579. })
  580. //
  581. // urlss = "14.215.128.96"
  582. // console.log()
  583. // data.clientType = 1
  584. // data.sn="RK3930C2301900044"
  585. // data.cardIp="14.215.128.96"
  586. // data.port=2044
  587. // if (data.clientType == 3) {
  588. // var players = AV.Player.fromWebSocket("wss://" + urlss + '/authVideoWebSocket?' + "clientType=" + data.clientType +
  589. // "&username=" + data.username + "&userCardId=" + data.userCardId);
  590. // } else if (data.clientType == 2) {
  591. // // var players = AV.Player.fromWebSocket("wss://" + urlss + '/shareWebSocket?' + "clientType=" + data.clientType +
  592. // // "&username=" + data.username + "&userCardId=" + data.userCardId + "&ip=" + data.ip);
  593. // var players = AV.Player.fromWebSocket(
  594. // "wss://test.androidscloud.com/videoWebSocket?clientType=1&cardIp=14.215.128.96&port=2005&sn=RK3930C2301900005");
  595. // } else {
  596. // var players = AV.Player.fromWebSocket("wss://" + urlss + '/videoWebSocket?' + "clientType=" + data.clientType +
  597. // "&cardIp=" + data.cardIp + "&port=" + data.port + "&sn=" + data.sn);
  598. // }
  599. // // debugger
  600. // var players = AV.Player.fromWebSocket('ws://14.215.128.96/authVideoWebSocket?clientType=3&username=WqXTc1593762177&userCardId=377');
  601. // players.play();
  602. // players.volume = 100
  603. //var players = AV.Player.fromWebSocket('ws://14.215.128.96/videoWebSocket?clientType=0&cardIp=30.30.30.58&port=9100&sn=RK3930C2301900060');
  604. var warid = {
  605. id: data.id,
  606. type: 1,
  607. sn: data.sn
  608. }
  609. //结束时间 type=2
  610. var warids = {
  611. id: data.id,
  612. type: 2,
  613. sn: data.sn
  614. }
  615. // $.ajax({})
  616. // 关闭浏览器
  617. // window.onbeforeunload = function() {}
  618. //撤销的array
  619. var cancelList = new Array();
  620. //撤销的次数
  621. var cancelIndex = 0;
  622. var inputType = 0 //输入类型 0:手写,1:键盘输入
  623. //判断是否ie
  624. var IE_HACK = (/msie/i.test(navigator.userAgent) &&
  625. !/opera/i.test(navigator.userAgent));
  626. // 云手机相关逻辑
  627. // var player = new Player({
  628. // size: {
  629. // width: 1280,
  630. // height: 720
  631. // }
  632. // });
  633. // var secanv = document.getElementById("wine");
  634. // secanv.appendChild(player.canvas);
  635. // console.log("player=========>>>>", player);
  636. // console.log("secanv>>>>", secanv);
  637. // &cardIp="+data.data.extranetIp+"&port="+data.data.extranetPort+"&sn="+data.data.sn
  638. $(function() {
  639. initCanvas();
  640. });
  641. //初始化
  642. var initCanvas = function() {
  643. }
  644. $("#voew").on("click", function() {})
  645. $("#box").on("click", function() {
  646. // draw_graph('pencil', this)
  647. })
  648. console.log(player)
  649. $('#mocan').on('click', function() {
  650. draw_graph('pencil', this)
  651. })
  652. // //初始化一下就可以了,
  653. let vConsole = new VConsole();
  654. // //你打印的数据 比如
  655. console.log('test');
  656. //就可像小程序一样的看了和调试了。
  657. $('.no-ne-an').on('click', function() {
  658. //结束时间 type=2
  659. let warids = {
  660. id: data.id,
  661. type: 2,
  662. sn: data.sn
  663. }
  664. $.ajax({
  665. url: baseUrl + "/api/game/v1/cloudGame/dev/getSn",
  666. data: warid,
  667. type: 'get',
  668. dataType: 'json',
  669. success: function(data) {
  670. history.go(-1)
  671. if (data.status == 0) {
  672. } else {
  673. alert(data.msg)
  674. }
  675. //
  676. }
  677. })
  678. })
  679. var btnMuted = document.querySelector("#btnMuted");
  680. btnMuted && (function() {
  681. var setHistory = function(left, top) {
  682. try {
  683. localStorage.setItem("muted-btn-loc", JSON.stringify({
  684. left: left,
  685. top: top
  686. }));
  687. } catch (ex) {}
  688. };
  689. var getHistory = function() {
  690. try {
  691. var value = localStorage.getItem("muted-btn-loc");
  692. if (!value) return null;
  693. value = JSON.parse(value);
  694. if (!value) return null;
  695. return value;
  696. } catch (ex) {
  697. return null
  698. }
  699. };
  700. var fixLoc = function(loc) {
  701. var rect = btnMuted.getBoundingClientRect();
  702. rect = {
  703. top: rect.top,
  704. left: rect.left,
  705. width: rect.width,
  706. height: rect.height
  707. }; //部分低版本浏览器,该属性为只读
  708. if (loc) {
  709. rect.left = loc.left;
  710. rect.top = loc.top;
  711. }
  712. var minX = 0;
  713. var minY = 0;
  714. var docRect = document.documentElement.getBoundingClientRect();
  715. var maxY = docRect.height - rect.height;
  716. var maxX = docRect.width - rect.width;
  717. var left = rect.left;
  718. var top = rect.top;
  719. left = Math.min(left, maxX);
  720. left = Math.max(left, minX);
  721. top = Math.min(top, maxY);
  722. top = Math.max(top, minY);
  723. console.log(rect.top, top, loc);
  724. if (loc || top !== rect.top || left !== rect.left) {
  725. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  726. }
  727. }
  728. window.addEventListener("resize", function() {
  729. fixLoc();
  730. });
  731. var touchPoint = {
  732. pageY: 0,
  733. pageX: 0
  734. };
  735. var currentLoc = {
  736. top: 0,
  737. left: 0,
  738. curTop: 0,
  739. curLeft: 0
  740. };
  741. var toMove = false;
  742. var touchmove = function(e) {
  743. e.preventDefault();
  744. var point = e.changedTouches[0];
  745. var top = -touchPoint.pageY + point.pageY;
  746. var left = -touchPoint.pageX + point.pageX;
  747. if (toMove) {
  748. top += currentLoc.top;
  749. left += currentLoc.left;
  750. currentLoc.curLeft = left;
  751. currentLoc.curTop = top;
  752. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  753. } else {
  754. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  755. toMove = true;
  756. }
  757. }
  758. };
  759. var touchend = function() {
  760. window.removeEventListener("touchmove", touchmove, {
  761. passive: false
  762. });
  763. window.removeEventListener("touchend", touchend, {
  764. passive: false
  765. });
  766. if (toMove) {
  767. setHistory(currentLoc.curLeft, currentLoc.curTop);
  768. fixLoc();
  769. } else {
  770. //按点击处理
  771. var set = $('.control-right-img').attr("data-id")
  772. if (set == '1') {
  773. $('.control-right-img').attr({
  774. "data-id": "2"
  775. })
  776. // $('.control-right-img').find('img').attr({
  777. // "src": "../static/img/musicturn.png"
  778. // })
  779. // players.volume = 100
  780. $(".leftmains").css({
  781. "right": "-4rem"
  782. })
  783. // console.log(players)
  784. // players.play();
  785. } else {
  786. $('.control-right-img').attr({
  787. "data-id": "1"
  788. })
  789. $(".leftmains").css({
  790. "right": "0rem"
  791. })
  792. // $('.control-right-img').find('img').attr({
  793. // "src": "../static/img/musicfalse.png"
  794. // })
  795. // players.volume = 0
  796. // players.off('pause');
  797. // players.pause();
  798. // var embed = document.embedPlay;
  799. // console.log(players, "fdsfdsf")
  800. }
  801. }
  802. }
  803. btnMuted.addEventListener("touchstart", function(e) {
  804. e.preventDefault();
  805. toMove = false;
  806. var point = e.changedTouches[0];
  807. touchPoint.pageX = point.pageX;
  808. touchPoint.pageY = point.pageY;
  809. var rect = e.target.getBoundingClientRect();
  810. currentLoc.top = rect.top;
  811. currentLoc.left = rect.left;
  812. window.addEventListener("touchmove", touchmove, {
  813. passive: false
  814. });
  815. window.addEventListener("touchend", touchend, {
  816. passive: false
  817. });
  818. }, {
  819. passive: false
  820. });
  821. var history = getHistory();
  822. if (history) {
  823. fixLoc(history);
  824. }
  825. btnMuted.classList.remove("hide");
  826. })();
  827. $(".boximg").on("click", function() {
  828. $(".mainbox").css({
  829. "display": "none"
  830. })
  831. })
  832. // 剪切板
  833. $(".sboxbu").on("click", function() {
  834. $(".sbox").css({
  835. "display": "none"
  836. })
  837. })
  838. // 剪切板
  839. $(".uploadss").on("click", function() {
  840. $(".sbox").css({
  841. "display": "none"
  842. })
  843. })
  844. $("#upload").on("click", function() {
  845. wx.miniProgram.switchTab({
  846. url: '/pages/home/home'
  847. })
  848. })
  849. function selectText(x) {
  850. if (document.selection) {
  851. var range = document.body.createTextRange();
  852. range.moveToElementText(x);
  853. range.select();
  854. } else if (window.getSelection) {
  855. var selection = window.getSelection();
  856. var range = document.createRange();
  857. selection.removeAllRanges();
  858. range.selectNodeContents(x);
  859. selection.addRange(range);
  860. }
  861. }
  862. function cp(x) {
  863. $(".mainbox").css({
  864. "display": "none"
  865. })
  866. $(".sbox").css({
  867. "display": "block"
  868. })
  869. selectText(x);
  870. document.execCommand("copy");
  871. }
  872. </script>
  873. <script type="text/javascript" src="jmuxer.js"></script>
  874. <script type="text/text/javascript" src="aac.js"></script>
  875. </body>
  876. </html>