export class musicPlayer { constructor(audioEl) { this.audioEl = audioEl // 音频上下文 this.audioCtx = null // 音源 this.audioSource = null // 时长 this.duration = 0 // 当前播放时间 this.currentTime = 0 // 播放进度 this.progress = 0 // 声音 this.volume = 20 // AnalyserNode 接口表示了一个可以提供实时频域和时域分析信息的节点 this.analyser = null // 音量节点 this.gainNode = null // 缓冲进度 this.timeRange = null // 是否播放中 this.playing = false } init() { // 音频上下文 this.audioCtx = new (window.AudioContext || window.webkitAudioContext)() if (!this.audioCtx) { throw new Error('audioCtx is null') } // 获取音频数据的节点 this.analyser = this.audioCtx.createAnalyser() // 音量节点 this.gainNode = this.audioCtx.createGain() this.gainNode.gain.value = 1 this.audioEl.volume = this.volume / 100 // 从