开发
API

BackgroundAudioManager.onPrev

监听用户在系统音乐播放面板点击上一曲事件(暂仅支持 iOS)。

语法

BackgroundAudioManager.onPrev(callback)

参数说明

Function callback

扫码体验

请使用字节宿主APP扫码

代码示例

开发者工具中预览

<!-- index.ttml -->
<button type="primary" bindtap="play">开始播放</button>
<!-- 音频开始播放后点击系统音乐播放面板上一首,出现弹窗提示 -->
// index.js
Page({
  onLoad() {
    const backgroundAudioManager = tt.getBackgroundAudioManager();
    backgroundAudioManager.title = "背景音乐";
    backgroundAudioManager.epname = "测试音频";
    backgroundAudioManager.singer = "测试";
    backgroundAudioManager.coverImgUrl =
      "https://s3.pstatp.com/toutiao/static/img/logo.201f80d.png";
    backgroundAudioManager.onPrev((res) => {
      tt.showToast({ title: "播放上一首" });
      backgroundAudioManager.src =
        "https//sf1-cdn-tos.douyinstatic.com/obj/microapp/frontend/sdk/0000-0002.mp3";
    });
    this.backgroundAudioManager = backgroundAudioManager;
  },
  play() {
    this.backgroundAudioManager.src =
      "https://sf1-cdn-tos.douyinstatic.com/obj/microapp/frontend/sdk/0000-0001.mp3";
    this.backgroundAudioManager.play();
  },
});

Bug & Tip

暂无

点击纠错
评价此篇文档