This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
appcat
/
sonist
Archived
1
0
Fork 0
master
宇天 2020-12-25 14:20:19 +08:00
parent 8348d50495
commit cabfa462a4
1 changed files with 7 additions and 4 deletions

View File

@ -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