|
@@ -15,7 +15,13 @@ PCMPlayer.prototype.init = function (option) {
|
|
|
this.interval = setInterval(this.flush, this.option.flushingTime);
|
|
|
this.maxValue = this.getMaxValue();
|
|
|
this.typedArray = this.getTypedArray();
|
|
|
- this.createContext();
|
|
|
+ $.alert({
|
|
|
+ title: '提示',
|
|
|
+ text: '开始使用云手机',
|
|
|
+ onOK: function () {
|
|
|
+ this.createContext();
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
PCMPlayer.prototype.getMaxValue = function () {
|
|
@@ -41,18 +47,14 @@ PCMPlayer.prototype.getTypedArray = function () {
|
|
|
};
|
|
|
|
|
|
PCMPlayer.prototype.createContext = function () {
|
|
|
- this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
|
- 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());
|
|
|
- }
|
|
|
- });
|
|
|
+ var handleSuccess = function (stream) {
|
|
|
+ this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
|
+ this.gainNode = this.audioCtx.createGain();
|
|
|
+ this.gainNode.gain.value = 1;
|
|
|
+ this.gainNode.connect(this.audioCtx.destination);
|
|
|
+ this.startTime = this.audioCtx.currentTime;
|
|
|
+ }
|
|
|
+ navigator.mediaDevices.getUserMedia({audio: true, video: true}).then(handleSuccess);
|
|
|
};
|
|
|
|
|
|
PCMPlayer.prototype.isTypedArray = function (data) {
|