WXtrialInterface.html 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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" 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.21: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 baseUrl = "http://192.168.199.243";
  446. var data = {}
  447. // 审核
  448. $.ajax({
  449. url: baseUrl + "/api/user/v1/config/download/isShow",
  450. data: {},
  451. type: 'get',
  452. dataType: 'json',
  453. success: function(data) {
  454. if (data.data) {
  455. $("#showsuss").show()
  456. } else {
  457. $("#showsuss").hide()
  458. }
  459. //
  460. }
  461. })
  462. var clientType = vars.find(e => {
  463. return e.startsWith('clientType')
  464. }) || ''
  465. // console.log(clientType)
  466. data.clientType = clientType.substring(11, clientType.length)
  467. // 小程序直接进入
  468. var diskName = vars.find(e => {
  469. return e.startsWith('diskName')
  470. }) || ''
  471. data.diskName = diskName.substring(9, diskName.length)
  472. // document.title = decodeURI(data.diskName)
  473. if (data.clientType == 1) {
  474. var cardIp = vars.find(e => {
  475. return e.startsWith('cardIp')
  476. }) || ''
  477. var port = vars.find(e => {
  478. return e.startsWith('port')
  479. }) || ''
  480. var sn = vars.find(e => {
  481. return e.startsWith('sn')
  482. }) || ''
  483. var demoTime = vars.find(e => {
  484. return e.startsWith('demoTime')
  485. }) || ''
  486. var id = vars.find(e => {
  487. return e.startsWith('id')
  488. }) || ''
  489. data.clientType = clientType.substring(11, clientType.length)
  490. data.cardIp = cardIp.substring(7, cardIp.length)
  491. data.port = port.substring(5, port.length)
  492. data.sn = sn.substring(3, sn.length)
  493. data.demoTime = demoTime.substring(9, demoTime.length)
  494. data.id = id.substring(3, id.length)
  495. } else if (data.clientType == 2) { //分享屏幕
  496. console.log("走到分享屏幕里面啦==========", data.clientTypes);
  497. $(".leftmains").css({
  498. "right": "-4rem"
  499. })
  500. $('.leftmains').hide()
  501. $('.bottommains').hide()
  502. $('#btnMuted').hide()
  503. let ip = vars.find(e => {
  504. return e.startsWith('ip')
  505. }) || ''
  506. var username = vars.find(e => {
  507. return e.startsWith('username')
  508. }) || ''
  509. var id = vars.find(e => {
  510. return e.startsWith('id')
  511. }) || ''
  512. var userCardId = vars.find(e => {
  513. return e.startsWith('userCardId')
  514. }) || ''
  515. data.id = id.substring(3, id.length)
  516. data.username = username.substring(9, username.length)
  517. data.ip = ip.substring(3, ip.length)
  518. data.userCardId = userCardId.substring(11, userCardId.length)
  519. } else {
  520. // $(".leftmains").css({
  521. // "right":"-4rem"
  522. // })
  523. // $('.leftmains').hide()
  524. // $('.bottommains').hide()
  525. // $('#btnMuted').hide()
  526. var username = vars.find(e => {
  527. return e.startsWith('username')
  528. }) || ''
  529. var userCardId = vars.find(e => {
  530. return e.startsWith('userCardId')
  531. }) || ''
  532. data.username = username.substring(9, username.length)
  533. data.userCardId = userCardId.substring(11, userCardId.length)
  534. console.log(data.ip)
  535. }
  536. // 心跳
  537. // var time = 1000 * 30;
  538. // var interval;
  539. // fun()
  540. //
  541. // function run() {
  542. //
  543. // interval = setInterval(fun, time);
  544. // }
  545. //
  546. // function fun() {
  547. // $.ajax({
  548. // url: baseUrl + "/api/game/v1/cloudGame/dev/get/cardSn",
  549. // data: {
  550. // sn: data.sn
  551. // },
  552. // type: 'get',
  553. // dataType: 'json',
  554. // success: function(data) {
  555. //
  556. // }
  557. // })
  558. //
  559. // };
  560. // run();
  561. // data.clientType=1
  562. // data.sn="RK3930C2301900044"
  563. // data.cardIp="14.215.128.96"
  564. // data.port=2044
  565. var orientation = 0 //0 竖屏,1横屏
  566. var winHeight = window.screen.height - window.innerHeight
  567. // var urlss = url[2]
  568. // var urlss='192.168.31.20'
  569. // var urlss = "14.215.128.96"
  570. var urlss = 'test.androidscloud.com'
  571. document.body.addEventListener('touchmove', function(e) {
  572. e.preventDefault()
  573. }, {
  574. passive: false
  575. })
  576. //
  577. // urlss = "14.215.128.96"
  578. // console.log()
  579. // data.clientType = 1
  580. // data.sn="RK3930C2301900044"
  581. // data.cardIp="14.215.128.96"
  582. // data.port=2044
  583. // if (data.clientType == 3) {
  584. // var players = AV.Player.fromWebSocket("wss://" + urlss + '/authVideoWebSocket?' + "clientType=" + data.clientType +
  585. // "&username=" + data.username + "&userCardId=" + data.userCardId);
  586. // } else if (data.clientType == 2) {
  587. // // var players = AV.Player.fromWebSocket("wss://" + urlss + '/shareWebSocket?' + "clientType=" + data.clientType +
  588. // // "&username=" + data.username + "&userCardId=" + data.userCardId + "&ip=" + data.ip);
  589. // var players = AV.Player.fromWebSocket(
  590. // "wss://test.androidscloud.com/videoWebSocket?clientType=1&cardIp=14.215.128.96&port=2005&sn=RK3930C2301900005");
  591. // } else {
  592. // var players = AV.Player.fromWebSocket("wss://" + urlss + '/videoWebSocket?' + "clientType=" + data.clientType +
  593. // "&cardIp=" + data.cardIp + "&port=" + data.port + "&sn=" + data.sn);
  594. // }
  595. // // debugger
  596. // var players = AV.Player.fromWebSocket('ws://14.215.128.96/authVideoWebSocket?clientType=3&username=WqXTc1593762177&userCardId=377');
  597. // players.play();
  598. // players.volume = 100
  599. //var players = AV.Player.fromWebSocket('ws://14.215.128.96/videoWebSocket?clientType=0&cardIp=30.30.30.58&port=9100&sn=RK3930C2301900060');
  600. var warid = {
  601. id: data.id,
  602. type: 1,
  603. sn: data.sn
  604. }
  605. //结束时间 type=2
  606. var warids = {
  607. id: data.id,
  608. type: 2,
  609. sn: data.sn
  610. }
  611. // $.ajax({})
  612. // 关闭浏览器
  613. // window.onbeforeunload = function() {}
  614. //撤销的array
  615. var cancelList = new Array();
  616. //撤销的次数
  617. var cancelIndex = 0;
  618. var inputType = 0 //输入类型 0:手写,1:键盘输入
  619. //判断是否ie
  620. var IE_HACK = (/msie/i.test(navigator.userAgent) &&
  621. !/opera/i.test(navigator.userAgent));
  622. // 云手机相关逻辑
  623. // var player = new Player({
  624. // size: {
  625. // width: 1280,
  626. // height: 720
  627. // }
  628. // });
  629. // var secanv = document.getElementById("wine");
  630. // secanv.appendChild(player.canvas);
  631. // console.log("player=========>>>>", player);
  632. // console.log("secanv>>>>", secanv);
  633. // &cardIp="+data.data.extranetIp+"&port="+data.data.extranetPort+"&sn="+data.data.sn
  634. $(function() {
  635. initCanvas();
  636. });
  637. //初始化
  638. var initCanvas = function() {
  639. }
  640. $("#voew").on("click", function() {})
  641. $("#box").on("click", function() {
  642. // draw_graph('pencil', this)
  643. })
  644. console.log(player)
  645. $('#mocan').on('click', function() {
  646. draw_graph('pencil', this)
  647. })
  648. // //初始化一下就可以了,
  649. let vConsole = new VConsole();
  650. // //你打印的数据 比如
  651. console.log('test');
  652. //就可像小程序一样的看了和调试了。
  653. $('.no-ne-an').on('click', function() {
  654. //结束时间 type=2
  655. let warids = {
  656. id: data.id,
  657. type: 2,
  658. sn: data.sn
  659. }
  660. $.ajax({
  661. url: baseUrl + "/api/game/v1/cloudGame/dev/getSn",
  662. data: warid,
  663. type: 'get',
  664. dataType: 'json',
  665. success: function(data) {
  666. history.go(-1)
  667. if (data.status == 0) {
  668. } else {
  669. alert(data.msg)
  670. }
  671. //
  672. }
  673. })
  674. })
  675. var btnMuted = document.querySelector("#btnMuted");
  676. btnMuted && (function() {
  677. var setHistory = function(left, top) {
  678. try {
  679. localStorage.setItem("muted-btn-loc", JSON.stringify({
  680. left: left,
  681. top: top
  682. }));
  683. } catch (ex) {}
  684. };
  685. var getHistory = function() {
  686. try {
  687. var value = localStorage.getItem("muted-btn-loc");
  688. if (!value) return null;
  689. value = JSON.parse(value);
  690. if (!value) return null;
  691. return value;
  692. } catch (ex) {
  693. return null
  694. }
  695. };
  696. var fixLoc = function(loc) {
  697. var rect = btnMuted.getBoundingClientRect();
  698. rect = {
  699. top: rect.top,
  700. left: rect.left,
  701. width: rect.width,
  702. height: rect.height
  703. }; //部分低版本浏览器,该属性为只读
  704. if (loc) {
  705. rect.left = loc.left;
  706. rect.top = loc.top;
  707. }
  708. var minX = 0;
  709. var minY = 0;
  710. var docRect = document.documentElement.getBoundingClientRect();
  711. var maxY = docRect.height - rect.height;
  712. var maxX = docRect.width - rect.width;
  713. var left = rect.left;
  714. var top = rect.top;
  715. left = Math.min(left, maxX);
  716. left = Math.max(left, minX);
  717. top = Math.min(top, maxY);
  718. top = Math.max(top, minY);
  719. console.log(rect.top, top, loc);
  720. if (loc || top !== rect.top || left !== rect.left) {
  721. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  722. }
  723. }
  724. window.addEventListener("resize", function() {
  725. fixLoc();
  726. });
  727. var touchPoint = {
  728. pageY: 0,
  729. pageX: 0
  730. };
  731. var currentLoc = {
  732. top: 0,
  733. left: 0,
  734. curTop: 0,
  735. curLeft: 0
  736. };
  737. var toMove = false;
  738. var touchmove = function(e) {
  739. e.preventDefault();
  740. var point = e.changedTouches[0];
  741. var top = -touchPoint.pageY + point.pageY;
  742. var left = -touchPoint.pageX + point.pageX;
  743. if (toMove) {
  744. top += currentLoc.top;
  745. left += currentLoc.left;
  746. currentLoc.curLeft = left;
  747. currentLoc.curTop = top;
  748. btnMuted.style.cssText += "left:" + left + "px;top:" + top + "px;";
  749. } else {
  750. if (Math.abs(top) >= 5 || Math.abs(left) >= 5) {
  751. toMove = true;
  752. }
  753. }
  754. };
  755. var touchend = function() {
  756. window.removeEventListener("touchmove", touchmove, {
  757. passive: false
  758. });
  759. window.removeEventListener("touchend", touchend, {
  760. passive: false
  761. });
  762. if (toMove) {
  763. setHistory(currentLoc.curLeft, currentLoc.curTop);
  764. fixLoc();
  765. } else {
  766. //按点击处理
  767. var set = $('.control-right-img').attr("data-id")
  768. if (set == '1') {
  769. $('.control-right-img').attr({
  770. "data-id": "2"
  771. })
  772. // $('.control-right-img').find('img').attr({
  773. // "src": "../static/img/musicturn.png"
  774. // })
  775. // players.volume = 100
  776. $(".leftmains").css({
  777. "right": "-4rem"
  778. })
  779. // console.log(players)
  780. // players.play();
  781. } else {
  782. $('.control-right-img').attr({
  783. "data-id": "1"
  784. })
  785. $(".leftmains").css({
  786. "right": "0rem"
  787. })
  788. // $('.control-right-img').find('img').attr({
  789. // "src": "../static/img/musicfalse.png"
  790. // })
  791. // players.volume = 0
  792. // players.off('pause');
  793. // players.pause();
  794. // var embed = document.embedPlay;
  795. // console.log(players, "fdsfdsf")
  796. }
  797. }
  798. }
  799. btnMuted.addEventListener("touchstart", function(e) {
  800. e.preventDefault();
  801. toMove = false;
  802. var point = e.changedTouches[0];
  803. touchPoint.pageX = point.pageX;
  804. touchPoint.pageY = point.pageY;
  805. var rect = e.target.getBoundingClientRect();
  806. currentLoc.top = rect.top;
  807. currentLoc.left = rect.left;
  808. window.addEventListener("touchmove", touchmove, {
  809. passive: false
  810. });
  811. window.addEventListener("touchend", touchend, {
  812. passive: false
  813. });
  814. }, {
  815. passive: false
  816. });
  817. var history = getHistory();
  818. if (history) {
  819. fixLoc(history);
  820. }
  821. btnMuted.classList.remove("hide");
  822. })();
  823. $(".boximg").on("click", function() {
  824. $(".mainbox").css({
  825. "display": "none"
  826. })
  827. })
  828. // 剪切板
  829. $(".sboxbu").on("click", function() {
  830. $(".sbox").css({
  831. "display": "none"
  832. })
  833. })
  834. // 剪切板
  835. $(".uploadss").on("click", function() {
  836. $(".sbox").css({
  837. "display": "none"
  838. })
  839. })
  840. $("#upload").on("click", function() {
  841. wx.miniProgram.switchTab({
  842. url: '/pages/home/home'
  843. })
  844. })
  845. function selectText(x) {
  846. if (document.selection) {
  847. var range = document.body.createTextRange();
  848. range.moveToElementText(x);
  849. range.select();
  850. } else if (window.getSelection) {
  851. var selection = window.getSelection();
  852. var range = document.createRange();
  853. selection.removeAllRanges();
  854. range.selectNodeContents(x);
  855. selection.addRange(range);
  856. }
  857. }
  858. function cp(x) {
  859. $(".mainbox").css({
  860. "display": "none"
  861. })
  862. $(".sbox").css({
  863. "display": "block"
  864. })
  865. selectText(x);
  866. document.execCommand("copy");
  867. }
  868. </script>
  869. <script type="text/javascript" src="jmuxer.js"></script>
  870. <script type="text/text/javascript" src="aac.js"></script>
  871. </body>
  872. </html>