WXtrialInterface.html 28 KB

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