From cabfa462a4bd3c0782132b3cdf8b1797c5cba38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Fri, 25 Dec 2020 14:20:19 +0800 Subject: [PATCH] update --- src/js/lib/audio/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/js/lib/audio/index.js b/src/js/lib/audio/index.js index 9cf7f73..6baf69e 100644 --- a/src/js/lib/audio/index.js +++ b/src/js/lib/audio/index.js @@ -10,6 +10,8 @@ import fetch from '../fetch/index.js' const { EventEmitter } = require('events') const util = require('util') +const AC = new AudioContext() + function hide(target, key, value) { Object.defineProperty(target, key, { value, @@ -21,15 +23,15 @@ function hide(target, key, value) { class AudioTrack { constructor(elem) { - var AC = new AudioContext() - this._el = elem this.gain = AC.createGain() this._track = AC.createMediaElementSource(elem) - .connect(this.gain) - .connect(AC.destination) + + this._track.connect(this.gain) + + this.gain.connect(AC.destination) this.__playFn = $.bind(elem, 'timeupdate', _ => { this.emit('play', elem.currentTime) @@ -51,6 +53,7 @@ class AudioTrack { this.removeAllListeners() this._track.disconnect() + // this._track.disconnect(AC.destination) this._el.src = '' this._el.currentTime = 0