start: function (e) {
// if (res.platform == ‘ios’) {
// this.audioCtx = wx.getBackgroundAudioManager();
// console.log(123);
// } else {
// this.audioCtx = wx.createInnerAudioContext();
// }
this.audioCtx.title=123;
let that=this;
let imgSrc = e.currentTarget.dataset.src;
this.audioCtx.src = imgSrc;
let sort = e.currentTarget.dataset.sort;
if (that.data.isplay==true){
this.audioCtx.play();
console.log(that.data.isplay);
that.setData({
isplay: false,
activeIndex:sort
})
}else{
wx.pauseBackgroundAudio()
this.audioCtx.pause();
that.setData({
isplay: true,
activeIndex: null
})
}
this.audioCtx.onEnded(()=>{
that.setData({
isplay: true,
activeIndex: null
})
})
},
<block wx:for="{{dataList}}" wx:key="{{item.id}}">
<audio src="{{path}}{{item.path}}" bindplay=“funplay” id=“myAudio”>
<view class=“audio”>
<view class=“one”>
<navigator url="/pages/voice_details/voice_details?id={{item.id}}&&teacherId={{item.teacherId}}" class=“score link”>{{item.sex}}-{{item.teacherName}}-{{item.cateName}}</navigator>
<view>{{item.name}}</view>
</view>
<image bindtap=‘start’ data-src="{{path}}{{item.path}}" data-sort="{{item.sort}}" data-id="{{item.id}}" src="{{activeIndex==index?img:img2}}" />
</view>
</audio>
</block>
代码片段是一种可分享的小项目,可用于分享小程序和小游戏的开发经验、展示组件和 API 的使用、复现开发问题等等。分享代码片段会得到一个链接,所有拥有此分享链接的人可以在工具中导入此代码片段。如果网页可点击的链接指向的是分享链接,那么点击链接也会自动打开工具进入代码片段导入页。代码片段