mp3录音文件 苹果端只能播放一次,安卓端能随意播放
发布于 5 年前 作者 tao46 4086 次浏览 来自 问答

安卓端能根据需求来重复点击播放

苹果ios端第一次点击能执行开始播放,第二次点击会拿到src地址然后下面就执行不下去了,然而切换其他的音频文件又可以播放

待解决问题:ios不能重复点击播放当前mp3文件,只会执行一次播放

2 回复

你好,麻烦提供一下出现问题的机型和微信版本,并且给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题

机型:苹果6

微信版本号:6.6.6

js代码:

// pages/others/detailChallenge/detailChallenge.js

const recorderManager = wx.getRecorderManager()

const innerAudioContext = wx.createInnerAudioContext()

Page({

/**

  * 页面的初始数据

  */

data: {

mineList: [],

take_message: [],

id: ‘’,

//  requesturl: conf.appConfigs.REQUESTURL,

// voice: conf.appConfigs.VOICE,

//  avatar_imgpath: conf.appConfigs.AVATAR_IMGURL,

nodata: true,//判断是否有数据

alldata: false,//判断是否全部加载数据

jiazai: true,

operate: 0,

clock: ‘’,

formatClock: ‘’,

keyboard: true,

tempFilePath: ‘’,

choose: ‘voice’,

curIndex: true,

focus: false,

checkNum: ‘0’,      //0公开   1私密

vioce: ‘’,          //录音路径

album: ‘’,          //图片路径

text: ‘’,            //文本内容

len: ‘’,             //文本字数

hidden: false,

timeOut: ‘’,

background: ‘#8abcb5’,

curIndex: ‘’,

send: false,

focus: false            //是否聚焦

},

// 播放录音

play: function (e) {

let that = this;

console.log(e);

let src = https://wxapi.qjy168.com/wxpic/buyyou/voices/2018/07/16/201807161543145.mp3;

console.log(‘src’, src);

innerAudioContext.autoplay = true

innerAudioContext.src = src,

innerAudioContext.onPlay(() => {

console.log(‘开始播放’);

that.setData({ background: ‘#fbaa52’ })

})

innerAudioContext.onError((res) => {

console.log(res.errMsg)

console.log(res.errCode)

})

innerAudioContext.onEnded(() => {

that.setData({ background: ‘#8abcb5’ })

})

},

})

//html代码

<view class=“detailChallenge”>

<view class=“show” catchtouchmove=‘true’>

<button style=‘color:red’ class=“send” bindtap=‘play’>播放mp3文件</button>

</view>

</view>

回到顶部