lite-cc-audio
v11.0.0
Published
```typescript const audioPlayer: IAudioPlayer;
Downloads
1
Readme
代码
IAudioPlayer - 音频播放器接口
const audioPlayer: IAudioPlayer;
// 获取音量
const volume = audioPlayer.volumn;
// 设置音量(0.0-1.0)
audioPlayer.volumn = 0.5;
// 销毁当前音频
audioPlayer.destory();
// 暂停
audioPlayer.pause();
// 循环播放
await audioPlayer.play(路径或者AudioClip);
// 循环一次
await audioPlayer.playOnce(路径或者AudioClip);
// 继续
audioPlayer.resume();
// 停止
audioPlayer.stop();
- AudioPlayer
const assetManager: AssetManager;
const ccFactory: CcFactoryBase;
// 所有播放器
const allPlayer: { [scene: string]: IAudioPlayer } = {};
const audioPlayer: AudioPlayerBase = new AudioPlayer(assetManager, ccFactory, 使用场景, allPlayer);
AudioPlayerFactoryBase - 音频播放器工厂
const audioPlayerFactory: AudioPlayerFactoryBase;
// 主场景音频播放器
const mainAudioPlayer = audioPlayerFactory.build('main');
// 战斗音频播放器
const battleAudioPlayer = audioPlayerFactory.build('battle');
- AudioPlayerFactory
const assetManager: AssetManager;
const ccFactory: CcFactoryBase;
const audioPlayerFactory: AudioPlayerFactoryBase = new AudioPlayerFactory(assetManager, ccFactory);