import { AudioGroupInterface } from "../interface/AudioGroupInterface" ; import { AudioInterface } from "../interface/AudioInterface" ; export class HTMLAudioGroup implements AudioGroupInterface { public name : string = "" ; private mAudioList : Array < AudioInterface > = new Array ( ) ; private _volume : number = 1 ; private _muted : boolean = false ; /**
     * 设置此组的音量
     */ public set volume ( volume ) { this . _volume = volume ; this . mAudioList . forEach ( v => { v . volume = v . volume ; } ) ; } public get volume ( ) : number { return this . _volume ; } /**
     * 组是否静音
     */ public set muted ( muted ) { this . _muted = muted ; this . mAudioList . forEach ( v => { v . muted = v . muted ; } ) ; } public get muted ( ) : boolean { return this . _muted ; } /**
     * 获取当前组里的音频
     */ public getAudios ( ) { let arr = new Array ( ) ; this . mAudioList . forEach ( v => { arr . push ( v ) ; } ) ; return arr ; } /**
     * 获取组里的资源名
     */ public getAlias ( ) { let arr = new Array ( ) ; this . mAudioList . forEach ( v => { if ( ! arr . includes ( v . alias ) ) { arr . push ( v . alias ) ; } } ) ; return arr ; } param alias public hasAlias ( alias ) { return this . getAlias ( ) . includes ( alias ) ; } public remove ( audio ) { this . mAudioList . remove ( audio ) ; } public addAudio ( audio ) { if ( ! this . mAudioList . includes ( audio ) ) { this . mAudioList . push ( audio ) ; } } }