WXtrialInterface.html 28 KB

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