IOS使用InnerAudioContext无法扬声器播放声音 插耳机就可以?
发布于 5 年前 作者 yuanxiuying 439 次浏览 来自 问答

手机是IOS7 微信版本7.0.10 手机系统版本是 10.0.3

<view>
  <button bindtap="play">播放</button>
  <button bindtap="zanting">暂停</button>
</view>

 

// pages/audio.js
const innerAudioContext = wx.createInnerAudioContext()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    innerAudioContext: null,
    poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
    name: '此时此刻',
    author: '许巍',
    src: 'http://sd.sycdn.kuwo.cn/e5a5e3afed1adb275215ffe15982450f/5e26b497/resource/n3/52/8/336768762.mp3',
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options{
    innerAudioContext.autoplay = true
    innerAudioContext.src = 'http://sd.sycdn.kuwo.cn/e5a5e3afed1adb275215ffe15982450f/5e26b497/resource/n3/52/8/336768762.mp3'
    innerAudioContext.onError((res) => {
      console.log(res.errMsg)
      console.log(res.errCode)
    })
  },

  play() {
    innerAudioContext.play()
  },
  zanting() {
    innerAudioContext.pause()
  },

})
1 回复

你好,是所有机型都这样么?麻烦提供这种格式的代码片段看下(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部