ios手机,上拉或者下拉或者接听微信语音电话,音乐暂停,未继续播放
发布于 4 年前 作者 ming26 14794 次浏览 来自 官方Issues

IOS手机,打开小程序,音乐播放,这个时候突然来个语音通话,接听、挂断(或者上拉、下拉)。音乐未播放,而是暂停了。期望继续播放。onShow、onHide事件都未触发。

const app = getApp()

Page({
  data: {
    audioCtx: null
  },
  onLoad: function () {
    wx.setInnerAudioOption({
      mixWithOther: false,
      obeyMuteSwitch: false
    });
    this.init();
  },
  init: function () {
    if (!this.data.audioCtx) {
      this.data.audioCtx = wx.createInnerAudioContext();
      this.data.audioCtx.src = '/static/00_00_37.30.mp3';
      this.data.audioCtx.autoplay = true;
      this.data.audioCtx.loop = true;
      this.data.audioCtx.onPause(() => {
        console.log('上拉或者下拉或者接听微信语音电话,这里面收到到了,onPause--')
      });
    }
  },
})

1 回复

你放onShow试试

回到顶部