huangxiaojing 4 years ago
parent
commit
a533832f31
1 changed files with 9 additions and 11 deletions
  1. 9 11
      screenIos/pcm-player.js

+ 9 - 11
screenIos/pcm-player.js

@@ -42,19 +42,17 @@ PCMPlayer.prototype.getTypedArray = function () {
 
 PCMPlayer.prototype.createContext = function () {
     this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
-    $.alert({
-        title: '提示',
-        text: '开始使用云手机',
-        onOK: () => {
-            this.audioCtx.resume().then(() => {
-                this.gainNode = this.audioCtx.createGain();
-                this.gainNode.gain.value = 1;
-                this.gainNode.connect(this.audioCtx.destination);
-                this.startTime = this.audioCtx.currentTime;
-            })
+    this.gainNode = this.audioCtx.createGain();
+    this.gainNode.gain.value = 1;
+    this.gainNode.connect(this.audioCtx.destination);
+    this.startTime = this.audioCtx.currentTime;
+    document.documentElement.addEventListener('mousedown', () => {
+        console.log(this.audioCtx.state);
+        if (this.audioCtx.state !== 'running') {
+            this.audioCtx.resume();
+            console.log(this.audioCtx.resume());
         }
     });
-
 };
 
 PCMPlayer.prototype.isTypedArray = function (data) {