1- import { AUDIO_EVENTS , BaseAudioPlayer } from "../BaseAudioPlayer" ;
1+ import { AUDIO_EVENTS , AudioErrorCode , BaseAudioPlayer } from "../BaseAudioPlayer" ;
22import AudioWorker from "./audio.worker?worker" ;
33import type { AudioMetadata , PlayerState , WorkerResponse } from "./types" ;
44
@@ -7,13 +7,6 @@ const HIGH_WATER_MARK = 30;
77/** 缓冲区低水位标记(秒),低于此值恢复解码 */
88const LOW_WATER_MARK = 10 ;
99
10- // const ERR_ABORTED = 1;
11- /** 网络错误码 */
12- const ERR_NETWORK = 2 ;
13- /** 解码错误码 */
14- const ERR_DECODE = 3 ;
15- // const ERR_SRC_NOT_SUPPORTED = 4;
16-
1710/**
1811 * 基于 FFmpeg WASM 的音频播放器实现
1912 *
@@ -159,7 +152,7 @@ export class FFmpegAudioPlayer extends BaseAudioPlayer {
159152 }
160153 } catch ( e ) {
161154 this . cleanupLoadPromise ( ) ;
162- this . handleError ( ( e as Error ) . message , ERR_NETWORK ) ;
155+ this . handleError ( ( e as Error ) . message , AudioErrorCode . NETWORK ) ;
163156 reject ( e ) ;
164157 }
165158 } ;
@@ -348,7 +341,7 @@ export class FFmpegAudioPlayer extends BaseAudioPlayer {
348341 * @param msg 错误消息
349342 * @param code 错误码
350343 */
351- private handleError ( msg : string , code : number = ERR_DECODE ) {
344+ private handleError ( msg : string , code : number = AudioErrorCode . DECODE ) {
352345 console . error ( "[FFmpegAudioPlayer]" , msg , code ) ;
353346
354347 this . _errorCode = code ;
@@ -381,7 +374,7 @@ export class FFmpegAudioPlayer extends BaseAudioPlayer {
381374 this . metadataReject ( new Error ( resp . error ) ) ;
382375 this . cleanupLoadPromise ( ) ;
383376 }
384- this . handleError ( resp . error , ERR_DECODE ) ;
377+ this . handleError ( resp . error , AudioErrorCode . DECODE ) ;
385378 break ;
386379 case "METADATA" :
387380 this . metadata = {
0 commit comments