|
@@ -15,13 +15,7 @@ PCMPlayer.prototype.init = function (option) {
|
|
|
this.interval = setInterval(this.flush, this.option.flushingTime);
|
|
|
this.maxValue = this.getMaxValue();
|
|
|
this.typedArray = this.getTypedArray();
|
|
|
- $.alert({
|
|
|
- title: '提示',
|
|
|
- text: '开始使用云手机',
|
|
|
- onOK: () => {
|
|
|
- this.createContext();
|
|
|
- }
|
|
|
- });
|
|
|
+ this.createContext();
|
|
|
};
|
|
|
|
|
|
PCMPlayer.prototype.getMaxValue = function () {
|
|
@@ -48,6 +42,11 @@ PCMPlayer.prototype.getTypedArray = function () {
|
|
|
|
|
|
PCMPlayer.prototype.createContext = function () {
|
|
|
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
|
+ console.log(this.audioCtx);
|
|
|
+ if (this.audioCtx.state === 'suspended' && 'ontouchstart' in window) {
|
|
|
+ var unlock = () => { this.audioCtx.resume(); };
|
|
|
+ document.body.addEventListener('touchstart', unlock, false);
|
|
|
+ }
|
|
|
this.gainNode = this.audioCtx.createGain();
|
|
|
this.gainNode.gain.value = 1;
|
|
|
this.gainNode.connect(this.audioCtx.destination);
|