Skip to content

音频‐使用示例

muzzik edited this page Jul 6, 2024 · 1 revision

播放

正常播放

mk.audio.play(this.audio);

重叠播放

// 需要最大重叠几次就包含几个 mk.audio_.unit
let overlap_effect_as = [this.audio, ...this.audio.clone(4)];

mk.audio.play(overlap_effect_as.find((v) => v.state === mk.audio_.state.stop)!);

分组播放

// 播放处于 pause 或 stop 状态的 effect 类型音频
mk.audio.get_group(global_config.audio.type.effect).play(mk.audio_.state.pause | mk.audio_.state.stop);

暂停

正常暂停

mk.audio.pause(this.audio);

暂停分组音频

mk.audio.get_group(global_config.audio.type.effect).pause();

暂停所有音频

mk.audio.pause_all();

恢复

正常恢复

mk.audio.play(this.audio);

恢复分组音频

mk.audio.get_group(global_config.audio.type.effect).play(mk.audio_.state.pause);

恢复所有音频

mk.audio.resume_all();

停止

正常停止

mk.audio.stop(this.audio);

停止分组音频

mk.audio.get_group(global_config.audio.type.effect).stop();

停止所有音频

mk.audio.stop_all();
Clone this wiki locally