要获取createInnerAudioContext的进度,您可以使用以下方法:

  1. 在createInnerAudioContext上添加一个onTimeUpdate事件监听器。每当音频播放器更新其进度时,该事件将被触发。
const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.src = 'your audio file';
innerAudioContext.onTimeUpdate(() => {
  console.log(innerAudioContext.currentTime);
});
innerAudioContext.play();
  1. 您还可以使用wx.getBackgroundAudioPlayerState()来获取背景音频的播放状态,包括当前播放时间和音频总时间。
wx.getBackgroundAudioPlayerState({
  success: (res) => {
    const { currentPosition, duration } = res;
    console.log(`当前播放时间:${currentPosition},音频总时间:${duration}`);
  }
});
微信小程序如何获取createInnerAudioContext的进度

原文地址: http://www.cveoy.top/t/topic/bCnV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录