选择本地音频组件,IOS获取失败,安卓正常
nitroge opened this issue · 0 comments
nitroge commented
问题:官方提供的在onCanplay内可以获取音频时长,然鹅在ios上并不行
解决方案:先静音播放-获取音频时长-销毁audio实例,完美解决
// 关闭声音!!!
ctx.volume = 0;
ctx.onTimeUpdate(() => {
if (ctx.duration > 0) {
this.audioDuration = ctx.duration;
ctx.destroy();
}
});
ctx.onCanplay(() => {
ctx.play();
});