This commit is contained in:
lixiao 2024-09-05 17:22:41 +08:00
parent 7e69ada2d2
commit cb459dfcc9

View File

@ -129,7 +129,8 @@ struct Index {
}
LogHelper.I("NativeSDK", "[Control Callback]: ")
})
await registerSoundCallback(() => {
await registerSoundCallback((project: number, idx: number) => {
this.playAudio(project, idx)
LogHelper.I("NativeSDK", "[Sound Callback]: ")
})
await setImageSize(500, 300)
@ -143,11 +144,21 @@ struct Index {
}
}
async playAudio(project: number, point: number) {
await this.player.setSource({
type: "raw",
url: audios[projectAudio[project][point]]
})
// 播放语音
async playAudio(project: number, idx: number) {
try {
await this.player.setSource({
type: "raw",
url: audios[projectAudio[project][idx]]
})
} catch (err) {
promptAction.showToast({
message: JSON.stringify(err?.message || err),
duration: 3000
})
LogHelper.E("View", JSON.stringify(err?.message || err))
}
}
// 初始化语音播放器