BackgroundAudioManager.onTimeUpdate

解释:音频进度更新事件

方法参数

Function callback

示例

在开发者工具中预览效果

扫码体验

BackgroundAudioManager.onTimeUpdate - 图1请使用百度APP扫码

图片示例

BackgroundAudioManager.onTimeUpdate - 图2

BackgroundAudioManager.onTimeUpdate - 图3

BackgroundAudioManager.onTimeUpdate - 图4

代码示例

  • 在 js 文件中
  1. Page({
  2. data: {
  3. duration: '',
  4. currentTime: ''
  5. },
  6. onLoad() {
  7. let that = this;
  8. const backgroundAudioManager = swan.getBackgroundAudioManager();
  9. backgroundAudioManager.title = '演员';
  10. backgroundAudioManager.epname = '演员';
  11. backgroundAudioManager.singer = '薛之谦';
  12. backgroundAudioManager.coverImgUrl = 'https://c.hiphotos.baidu.com/super/pic/item/8b13632762d0f703e34c0f6304fa513d2797c597.jpg';
  13. backgroundAudioManager.onTimeUpdate(function(res) {
  14. console.log('backgroundAudioManager.onTimeUpdate', res)
  15. that.setData({
  16. duration: res.duration,
  17. currentTime: res.currentTime
  18. })
  19. });
  20. this.backgroundAudioManager = backgroundAudioManager;
  21. this.backgroundAudioManager.src = 'https://vd3.bdstatic.com/mda-ic7mxzt5cvz6f4y5/mda-ic7mxzt5cvz6f4y5.mp3';
  22. this.backgroundAudioManager.play();
  23. }
  24. });