Commit ee71f7f3 authored by wangxuelai's avatar wangxuelai

'录音播放部分bug修改'

parent a5c28704
......@@ -516,6 +516,14 @@
bindtap="playvoice"
>
</view>
<view
class="action-mask"
wx:if="{{audioStorage[filter.jsonParse(clock.review[2].audio).src] && audioStorage[filter.jsonParse(clock.review[2].audio).src].play}}"
data-value="{{filter.jsonParse(clock.review[2].audio).src}}"
data-duration="{{filter.jsonParse(clock.review[2].audio).duration}}"
bindtap="pausevoice"
>
</view>
<view
class="sjd-small-icon-box"
wx:if="{{!audioStorage[filter.jsonParse(clock.review[2].audio).src] || !audioStorage[filter.jsonParse(clock.review[2].audio).src].play}}"
......
......@@ -170,13 +170,12 @@ Page({
let dakarole = LocalStorage.getItem('dakarole');
},
onHide: function () { // Do something when page hide.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
clearTimeout(this.setTimeout)
},
onUnload: function () { // Do something when page close.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
this.setData({
audioStorage: {
......@@ -837,14 +836,14 @@ Page({
audioStorage[value].innerAudioContext.onTimeUpdate((e) => {
console.log('sss');
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value].isWaiting) {
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(value);
audioStorage[value].isWaiting = false
that.setData({
audioStorage,
})
}
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(value);
audioStorage[value].isWaiting = false
that.setData({
audioStorage,
})
// if (audioStorage[value].isWaiting) {
// }
})
audioStorage[value].innerAudioContext.onError((e)=>{
const { actPalyaudioValue, audioStorage} = this.data
......@@ -934,15 +933,15 @@ Page({
})
audioStorage[value].innerAudioContext.onTimeUpdate((e) => {
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value].isWaiting) {
console.log('22222222222222222');
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(value);
audioStorage[value].isWaiting = false
that.setData({
audioStorage,
})
}
console.log('22222222222222222');
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(value);
audioStorage[value].isWaiting = false
that.setData({
audioStorage,
})
// if (audioStorage[value].isWaiting) {
// }
})
audioStorage[value].innerAudioContext.onError((e)=>{
const { actPalyaudioValue, audioStorage} = this.data
......
......@@ -204,12 +204,11 @@ Page({
this.getBetweenDateStr(this.data.params.startDate,this.data.params.endDate);
},
onHide: function () { // Do something when page hide.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
onUnload: function () { // Do something when page close.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
this.setData({
audioStorage: {
......@@ -692,7 +691,6 @@ Page({
audioStorage[value].innerAudioContext.src = audioorigin(value);
audioStorage[value].innerAudioContext.obeyMuteSwitch = false;
audioStorage[value].innerAudioContext.onWaiting((e)=>{
console.log('等待中');
const { actPalyaudioValue, audioStorage} = this.data;
// if(audioStorage[value].isWaiting){
// return
......@@ -714,7 +712,6 @@ Page({
// that.voiceIntervalPlay(value);
// })
audioStorage[value].innerAudioContext.onTimeUpdate((e) => {
console.log('sss');
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value].isWaiting) {
clearInterval(that.data.voiceInterval);
......@@ -793,7 +790,6 @@ Page({
audioStorage[value].innerAudioContext.src = audioorigin(value);
audioStorage[value].innerAudioContext.obeyMuteSwitch = false;
audioStorage[value].innerAudioContext.onWaiting((e)=>{
console.log(value, '等待1111');
if (audioStorage[value] && !audioStorage[value].play) {
const { actPalyaudioValue, audioStorage} = this.data
// if(audioStorage[value].isWaiting){
......@@ -814,7 +810,6 @@ Page({
audioStorage[value].innerAudioContext.onTimeUpdate((e) => {
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value].isWaiting) {
console.log('22222222222222222');
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(value);
audioStorage[value].isWaiting = false
......@@ -1354,7 +1349,6 @@ Page({
if (dateList[0] == endDay[0] && dateList[1] == Number(endDay[1]) && dateList[2] == Number(endDay[2])) {
i = 1;
}
console.log(dateList[0])
};
const dateResult = [];
......@@ -1479,7 +1473,6 @@ Page({
}
break;
case 'up': // 页面上拉刷新
console.log(33)
let list = this.data.classList;
let _listGet = data.list.map(item=>{
return {
......
......@@ -161,12 +161,11 @@ Page({
}
},
onHide: function () { // Do something when page hide.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
onUnload: function () { // Do something when page close.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
this.setData({
audioStorage: {
......
......@@ -113,12 +113,10 @@ Page({
// this.transformSelectTeachers();
},
onHide: function() { // Do something when page hide.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
onUnload: function() { // Do something when page close.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
......
......@@ -154,7 +154,6 @@ Page({
*/
onHide: function () {
this.data.showRefresh = false;
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
......@@ -163,7 +162,6 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
this.innerAudioContext.pause();
this.setData({
// advertisementshow: false,
audioStorage: {}
......@@ -1084,98 +1082,6 @@ Page({
})
},
// 跟录音相关的操作
// 带Single是表彰墙的音频
playvoiceSingle(e) {
const {
value,
duration
} = e.currentTarget.dataset;
this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.obeyMuteSwitch = false;
this.resetAudiosPlayStatus();
clearInterval(this.data.voiceInterval);
let audioStorage = this.data.audioStorage;
if (!audioStorage[value]) {
audioStorage[value] = {
play: true,
currentTime: 0,
duration
}
} else {
if (audioStorage[value].currentTime == audioStorage[value].duration) {
audioStorage[value].currentTime = 0;
audioStorage[value].play = true;
} else {
audioStorage[value].play = true;
}
}
this.innerAudioContext.seek(audioStorage[value].currentTime)
this.innerAudioContext.play();
this.voiceIntervalPlay(value);
this.setData({
audioStorage,
})
},
pausevoiceSingle(e) {
const {
value
} = e.currentTarget.dataset;
let audioStorage = this.data.audioStorage;
audioStorage[value].play = false;
this.setData({
audioStorage,
})
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
},
slidestartSingle(e) {
const {
value,
slide
} = e.currentTarget.dataset;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则先暂停音乐盒计时器 播放按钮状态不需要改
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
},
slideendSingle(e) {
const {
value,
slide
} = e.currentTarget.dataset;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则启用定时器 播放按钮状态不需要改
// clearInterval(this.data.voiceInterval);
this.innerAudioContext.play();
this.voiceIntervalPlay(value);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
},
voiceslideSingle(e) {
const {
value,
duration
} = e.currentTarget.dataset;
const slide = e.detail.value;
let audioStorage = this.data.audioStorage;
if (!audioStorage[value]) {
audioStorage[value] = {
play: false,
currentTime: slide,
duration
}
} else {
audioStorage[value].currentTime = slide;
audioStorage[value].isWaiting = true;
}
this.innerAudioContext.seek(slide);
this.setData({
audioStorage,
})
},
// 带Single是表彰墙的音频
// 跟录音相关的操作
// 视频播放相关代码
playvideo(e) {
......
This diff is collapsed.
......@@ -446,14 +446,14 @@ Page({
audioStorage[value].innerAudioContext.onTimeUpdate((e) => {
console.log('sss');
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value].isWaiting) {
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(value);
audioStorage[value].isWaiting = false
that.setData({
audioStorage,
})
}
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(value);
audioStorage[value].isWaiting = false
that.setData({
audioStorage,
})
// if (audioStorage[value].isWaiting) {
// }
})
audioStorage[value].innerAudioContext.onError((e)=>{
const { actPalyaudioValue, audioStorage} = this.data
......
......@@ -266,12 +266,11 @@ Page({
}
},
onHide: function () { // Do something when page hide.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
onUnload: function () { // Do something when page close.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus();
this.setData({
audioStorage: {
}
......@@ -475,6 +474,10 @@ Page({
src: '',
duration: 0
} : JSON.parse(data.audio),
privateAudioInfo: data.audio == '' ? {
src: '',
duration: 0
} : JSON.parse(data.audio),
privatecomment: data.content || data.audio ? true:false,
peid:data.id,
})
......@@ -812,8 +815,10 @@ Page({
})
},
playvoice (e) {
const {value, duration} = e.detail;
// const {value, duration} = e.detail;
const {value, duration} = e.currentTarget.dataset;
const that = this;
console.log(e, 'e.detail');
// this.innerAudioContext.src = audioorigin(value);
// this.innerAudioContext.obeyMuteSwitch = false;
wx.getNetworkType({
......@@ -833,7 +838,6 @@ Page({
audioStorage[value].innerAudioContext.src = audioorigin(value);
audioStorage[value].innerAudioContext.obeyMuteSwitch = false;
audioStorage[value].innerAudioContext.onWaiting((e)=>{
console.log('等待中');
const { actPalyaudioValue, audioStorage} = this.data;
// if(audioStorage[value].isWaiting){
// return
......@@ -855,7 +859,6 @@ Page({
// that.voiceIntervalPlay(value);
// })
audioStorage[value].innerAudioContext.onTimeUpdate((e) => {
console.log('sss');
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value].isWaiting) {
clearInterval(that.data.voiceInterval);
......@@ -907,7 +910,8 @@ Page({
})
},
pausevoice (e) {
const {value} = e.detail;
// const {value} = e.detail;
const {value, duration} = e.currentTarget.dataset;
let audioStorage = this.data.audioStorage;
audioStorage[value].play = false;
this.setData({
......@@ -917,12 +921,14 @@ Page({
clearInterval(this.data.voiceInterval);
},
voiceslide (e) {
const {value, slide, duration} = e.detail;
const {value, duration} = e.currentTarget.dataset;
const slide = e.detail.value;
let audioStorage = this.data.audioStorage;
const that = this;
wx.getNetworkType({
success: (res) => {
if (res.networkType != 'none') {
console.log(audioStorage, 'audioStorage');
if (!audioStorage[value]) {
audioStorage[value] = {
play: false,
......@@ -986,6 +992,7 @@ Page({
clearInterval(this.data.voiceInterval);
// audioStorage[value].innerAudioContext.seek(0);
} else {
console.log(value, 'value');
audioStorage[value].currentTime = slide;
// audioStorage[value].innerAudioContext.seek(slide);
}
......@@ -1018,7 +1025,9 @@ Page({
},
// voicesliding
slidestart (e) {
const {value, slide} = e.detail;
const {value, slide} = e.currentTarget.dataset;
console.log({value, slide});
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则先暂停音乐盒计时器 播放按钮状态不需要改
audioStorage[value].innerAudioContext.pause();
......
......@@ -101,18 +101,18 @@
<text class="sjd-small-radio-time" wx:if="{{!audioStorage[audioitem.src] || !audioStorage[audioitem.src].play}}">{{filter.voiceTimeFormat(audioitem.duration)}}</text>
</view> -->
<view class="sjd-radio-box" >
<view class="play-btn" data-value="{{audioitem.src}}" data-duration="{{audioitem.duration}}" bindtap="playvoice" wx:if="{{!audioStorage[audioitem.src] || !audioStorage[audioitem.src].play}}">
<view class="play-btn" data-value="{{audioitem.src}}" data-duration="{{audioitem.duration}}" bindtap="playvoice" wx:if="{{(!audioStorage[audioitem.src] || !audioStorage[audioitem.src].play) && (!audioStorage[audioitem.src].isWaiting)}}">
<image class="play-btn-icon" src="{{imageRoot}}2b/common/playicon.png?{{imageVersion}}" ></image>
</view>
<!-- <view class="pause-btn" wx:if="{{audioStorage[audioitem.src] && audioStorage[audioitem.src].play}}" data-value="{{audioitem.src}}" bindtap="pausevoice" data-duration="{{audioitem.duration}}">
<image class="pause-btn-icon" src="{{imageRoot}}2b/common/pauseicon.png?{{imageVersion}}" ></image>
</view> -->
<view class="pause-btn load-box" wx:if="{{audioStorage[audioitem.src].isWaiting && audioitem.src == actionsPalyvalue}}" >
<view class="pause-btn load-box" wx:if="{{audioStorage[audioitem.src].isWaiting}}" >
<cssloading size="{{6}}"/>
</view>
<view
class="pause-btn"
wx:if="{{audioStorage[audioitem.src] && audioStorage[audioitem.src].play && (!audioStorage[audioitem.src].isWaiting || audioitem.src != actionsPalyvalue)}}"
wx:if="{{audioStorage[audioitem.src] && audioStorage[audioitem.src].play && (!audioStorage[audioitem.src].isWaiting)}}"
data-value="{{audioitem.src}}"
data-index="{{index}}"
data-duration="{{audioitem.duration}}"
......@@ -299,16 +299,16 @@
<view class="sjd-small-radio-box mb24" >
<view class="action-mask" wx:if="{{!audioStorage[audioInfo.src] || !audioStorage[audioInfo.src].play}}" data-value="{{audioInfo.src}}" data-duration="{{audioInfo.duration}}" bindtap="playvoice"></view>
<view class="action-mask" wx:if="{{audioStorage[audioInfo.src] && audioStorage[audioInfo.src].play}}" data-value="{{audioInfo.src}}" data-duration="{{audioInfo.duration}}" bindtap="pausevoice"></view>
<view class="sjd-small-icon-box" wx:if="{{!audioStorage[audioInfo.src] || !audioStorage[audioInfo.src].play}}">
<view class="sjd-small-icon-box" wx:if="{{(!audioStorage[audioInfo.src] || !audioStorage[audioInfo.src].play) && !audioStorage[audioInfo.src].isWaiting}}">
</view>
<!-- <view class="sjd-small-icon-box play" wx:if="{{audioStorage[audioInfo.src] && audioStorage[audioInfo.src].play}}">
</view> -->
<view
class="sjd-small-icon-box play"
wx:if="{{audioStorage[audioInfo.src] && audioStorage[audioInfo.src].play && (!audioStorage[audioInfo.src].isWaiting || audioInfo.src != actPalyaudioValue)}}"
wx:if="{{audioStorage[audioInfo.src] && audioStorage[audioInfo.src].play && (!audioStorage[audioInfo.src].isWaiting)}}"
>
</view>
<view class="sjd-small-icon-box" style="background: none;" wx:if="{{audioStorage[audioInfo.src].isWaiting && audioInfo.src == actPalyaudioValue}}" >
<view class="sjd-small-icon-box" style="background: none;" wx:if="{{audioStorage[audioInfo.src].isWaiting}}" >
<cssloading size="{{4}}"/>
</view>
<text class="sjd-small-radio-time" selectable="false" space="false" decode="false" wx:if="{{audioStorage[audioInfo.src] && audioStorage[audioInfo.src].play}}">{{audioStorage[audioInfo.src] && filter.voiceTimeFormat(audioStorage[audioInfo.src].currentTime) || filter.voiceTimeFormat(0)}}</text>
......@@ -409,16 +409,16 @@
<view class="sjd-small-radio-box mb24" >
<view class="action-mask" wx:if="{{!audioStorage[privateAudioInfo.src] || !audioStorage[audioInprivateAudioInfofo.src].play}}" data-value="{{privateAudioInfo.src}}" data-duration="{{privateAudioInfo.duration}}" bindtap="playvoice"></view>
<view class="action-mask" wx:if="{{audioStorage[privateAudioInfo.src] && audioStorage[privateAudioInfo.src].play}}" data-value="{{privateAudioInfo.src}}" data-duration="{{privateAudioInfo.duration}}" bindtap="pausevoice"></view>
<view class="sjd-small-icon-box" wx:if="{{!audioStorage[privateAudioInfo.src] || !audioStorage[privateAudioInfo.src].play}}">
<view class="sjd-small-icon-box" wx:if="{{(!audioStorage[privateAudioInfo.src] || !audioStorage[privateAudioInfo.src].play) && (!audioStorage[privateAudioInfo.src].isWaiting)}}">
</view>
<!-- <view class="sjd-small-icon-box play" wx:if="{{audioStorage[privateAudioInfo.src] && audioStorage[privateAudioInfo.src].play}}">
</view> -->
<view
class="sjd-small-icon-box play"
wx:if="{{audioStorage[privateAudioInfo.src] && audioStorage[privateAudioInfo.src].play && (!audioStorage[privateAudioInfo.src].isWaiting || privateAudioInfo.src != actPalyaudioValue)}}"
wx:if="{{audioStorage[privateAudioInfo.src] && audioStorage[privateAudioInfo.src].play && (!audioStorage[privateAudioInfo.src].isWaiting)}}"
>
</view>
<view class="sjd-small-icon-box" style="background: none;" wx:if="{{audioStorage[privateAudioInfo.src].isWaiting && privateAudioInfo.src == actPalyaudioValue}}" >
<view class="sjd-small-icon-box" style="background: none;" wx:if="{{audioStorage[privateAudioInfo.src].isWaiting}}" >
<cssloading size="{{4}}"/>
</view>
<text class="sjd-small-radio-time" selectable="false" space="false" decode="false" wx:if="{{audioStorage[privateAudioInfo.src] && audioStorage[privateAudioInfo.src].play}}">{{audioStorage[privateAudioInfo.src] && filter.voiceTimeFormat(audioStorage[privateAudioInfo.src].currentTime) || filter.voiceTimeFormat(0)}}</text>
......
......@@ -43,7 +43,6 @@ Page({
}
},
onLoad: function (options) { // Do some initialize when page load.
this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器
const {
id,
} = options;
......
......@@ -91,9 +91,9 @@ Page({
circleInfo: {},
clockListLoading: false,
qrcodeGenerating: false,
// audioStorage: {
audioStorage: {
// },
},
currentVoice: '', // 当前播放的录音
voiceInterval: null,
backTopValue: false, //返回顶部
......@@ -171,12 +171,11 @@ Page({
}
},
onHide: function() {
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
onUnload: function() {
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
this.setData({
audioStorage: {}
})
......@@ -1060,6 +1059,8 @@ Page({
},
resetAudiosPlayStatus () { // 点击一个录音的时候把其他的录音状态改成暂停状态
let audioStorage = this.data.audioStorage;
console.log('dadsad');
console.log(Object.keys(audioStorage), 'dadsad');
Object.keys(audioStorage).forEach((key) => {
audioStorage[key].play = false;
audioStorage[key].isWaiting = false;
......
......@@ -116,7 +116,7 @@ Page({
clockdate: ""
},
onLoad: function (options) { // Do some initialize when page load.
this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器
// this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器
const {
id,
tid,
......@@ -149,18 +149,18 @@ Page({
let dakarole = LocalStorage.getItem('dakarole');
},
onHide: function () { // Do something when page hide.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
// this.innerAudioContext.pause();
// this.resetAudiosPlayStatus()
// clearInterval(this.data.voiceInterval);
},
onUnload: function () { // Do something when page close.
this.innerAudioContext.pause();
this.setData({
audioStorage: {
// this.innerAudioContext.pause();
// this.setData({
// audioStorage: {
}
})
clearInterval(this.data.voiceInterval);
// }
// })
// clearInterval(this.data.voiceInterval);
},
onPullDownRefresh: function () { // Do something when pull down.
......@@ -720,196 +720,6 @@ Page({
},
// 跟录音相关的操作
// 跟录音相关的操作
// 播放录音的相关操作
// 格式是以录音名字为key value为{play: true || false, currentTime: 0}的一个对象
voiceIntervalPlay(value) { // 初始化录音的状态
let voiceInterval = setInterval(() => {
let audioStorage = this.data.audioStorage;
let currentTime = ++audioStorage[value].currentTime;
this.setData({
audioStorage
})
if (currentTime >= this.data.audioStorage[value].duration) {
audioStorage[value].play = false;
audioStorage[value].currentTime = 0;
this.setData({
audioStorage
})
clearInterval(this.data.voiceInterval);
}
}, 1000);
this.setData({
voiceInterval
})
},
playvoice(e) {
const {
value,
duration
} = e.detail;
const that = this;
this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.obeyMuteSwitch = false;
that.resetAudiosPlayStatus();
clearInterval(that.data.voiceInterval);
let audioStorage = that.data.audioStorage;
if (!audioStorage[value]) {
audioStorage[value] = {
play: true,
currentTime: 0,
duration,
isWaiting: true
}
} else {
if (audioStorage[value].currentTime == audioStorage[value].duration) {
audioStorage[value].currentTime = 0;
audioStorage[value].play = true;
} else {
audioStorage[value].play = true;
}
}
this.innerAudioContext.onWaiting((e)=>{
const { actPalyaudioValue, audioStorage} = this.data
if(audioStorage[actPalyaudioValue].isWaiting){
return
}
audioStorage[actPalyaudioValue].isWaiting = true
that.setData({
audioStorage,
})
setTimeout((e)=>{
this.data.audioStorage[actPalyaudioValue].isWaiting = false;
this.setData({
audioStorage: this.data.audioStorage
})
},5000)
})
this.innerAudioContext.onTimeUpdate((e) => {
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[actPalyaudioValue].isWaiting) {
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(actPalyaudioValue);
audioStorage[actPalyaudioValue].isWaiting = false
that.setData({
audioStorage,
})
}
})
this.innerAudioContext.onCanplay((e)=>{
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[actPalyaudioValue].isWaiting) {
clearInterval(that.data.voiceInterval);
that.voiceIntervalPlay(actPalyaudioValue);
audioStorage[actPalyaudioValue].isWaiting = false
that.setData({
audioStorage,
})
}
})
this.innerAudioContext.seek(audioStorage[value].currentTime)
this.innerAudioContext.play();
this.innerAudioContext.onError((e)=>{
const { actPalyaudioValue, audioStorage} = this.data
audioStorage[actPalyaudioValue].isWaiting = false;
audioStorage[actPalyaudioValue].play = false;
wx.showToast({
title: '音频播放出错啦',
icon: 'none',
duration: 2000
})
that.setData({
audioStorage,
})
});
//that.voiceIntervalPlay(value);
that.setData({
audioStorage,
actPalyaudioValue:value
})
},
pausevoice(e) {
const {
value
} = e.detail;
let audioStorage = this.data.audioStorage;
audioStorage[value].play = false;
this.setData({
audioStorage,
})
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
},
voiceslide(e) {
const {
value,
slide,
duration
} = e.detail;
let audioStorage = this.data.audioStorage;
if (!audioStorage[value]) {
audioStorage[value] = {
play: false,
currentTime: slide,
duration
}
} else {
audioStorage[value].currentTime = slide;
audioStorage[value].isWaiting = true;
}
this.innerAudioContext.seek(slide);
this.setData({
audioStorage,
})
},
slidestart(e) {
const {
value,
slide
} = e.detail;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则先暂停音乐盒计时器 播放按钮状态不需要改
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
},
slideend(e) {
const {
value,
slide
} = e.detail;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则启用定时器 播放按钮状态不需要改
// clearInterval(this.data.voiceInterval);
this.innerAudioContext.play();
this.voiceIntervalPlay(value);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
},
resetAudiosPlayStatus() { // 点击一个录音的时候把其他的录音状态改成暂停状态
let audioStorage = this.data.audioStorage;
Object.keys(audioStorage).forEach((key) => {
audioStorage[key].play = false
});
this.setData({
audioStorage,
})
},
delvoice(e) {
const {
value
} = e.detail;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 删除录音的操作要把录音销毁掉
delete audioStorage[value]
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
}
this.setData({
audioStorage,
})
},
// 跟录音相关的操作
goindex() {
const dakarole = LocalStorage.getItem('dakarole');
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -56,9 +56,9 @@ Page({
upload: false
},
placeholder: '请输入打卡主题的具体要求,如:演唱歌曲《小小少年》\r\n演唱歌曲《小小少年》,具体要求\r\n1.跟随伴奏唱一段副歌\r\n2.视频录下唱歌过程\r\n3.上传歌唱视频打卡成功\r\n如果有该歌曲示例视频,你可以点击上传视频,供学员参考。',
// audioStorage: {
audioStorage: {
// },
},
currentVoice: '', // 当前播放的录音
voiceInterval: null,
showWarn: false,
......@@ -74,7 +74,6 @@ Page({
},
},
onLoad: function (options) { // Do some initialize when page load.
// this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器
const {
id,
tid,
......@@ -105,12 +104,11 @@ Page({
onShow: function () { // Do something when page show.
},
onHide: function () { // Do something when page hide.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
onUnload: function () { // Do something when page close.
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
this.setData({
audioStorage: {
......
This diff is collapsed.
......@@ -128,34 +128,6 @@ Page({
},
onLoad: function(options) { // Do some initialize when page load.
const that = this;
// this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器
// this.innerAudioContext.onWaiting((e)=>{
// const { actPalyaudioValue, audioStorage} = this.data
// if(audioStorage[actPalyaudioValue].isWaiting){
// return
// }
// audioStorage[actPalyaudioValue].isWaiting = true
// that.setData({
// audioStorage,
// })
// setTimeout((e)=>{
// this.data.audioStorage[actPalyaudioValue].isWaiting = false;
// this.setData({
// audioStorage: this.data.audioStorage
// })
// },5000)
// })
// this.innerAudioContext.onTimeUpdate((e) => {
// const { actPalyaudioValue, audioStorage} = this.data
// if (audioStorage[actPalyaudioValue].isWaiting) {
// clearInterval(that.data.voiceInterval);
// that.voiceIntervalPlay(actPalyaudioValue);
// audioStorage[actPalyaudioValue].isWaiting = false
// that.setData({
// audioStorage,
// })
// }
// })
const {id, tid,sid} = options;
this.setData({
id,
......@@ -837,7 +809,6 @@ Page({
// that.voiceIntervalPlay(value);
// })
audioStorage[value].innerAudioContext.onTimeUpdate((e) => {
console.log('sss');
const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[value].isWaiting) {
clearInterval(that.data.voiceInterval);
......@@ -889,6 +860,7 @@ Page({
})
},
pausevoice (e) {
console.log('ddddddddddddddddddddd');
const {value} = e.detail;
let audioStorage = this.data.audioStorage;
audioStorage[value].play = false;
......@@ -1164,7 +1136,6 @@ Page({
// 选择点评类型的代码
goCommentEditor (e) {
const { clock } = e.detail;
console.log(Number(clock.class_id), 'clock');
this.setData({
goCommentEditorInfo: {
show: true,
......
This diff is collapsed.
......@@ -23,18 +23,18 @@
data-index="{{index}}"
data-duration="{{item.duration}}"
bindtap="playvoice"
wx:if="{{!audioStorage[item.value] || !audioStorage[item.value].play}}"
wx:if="{{(!audioStorage[item.value] || !audioStorage[item.value].play) && (!audioStorage[item.value].isWaiting)}}"
>
<image class="play-btn-icon" src="{{imageRoot}}2b/common/playicon.png?{{imageVersion}}" ></image>
</view>
<!-- 播放的icon -->
<!-- 暂停的icon -->
<view class="pause-btn load-box" wx:if="{{audioStorage[item.value].isWaiting && item.value == actionsPalyvalue}}" >
<view class="pause-btn load-box" wx:if="{{audioStorage[item.value].isWaiting}}" >
<cssloading size="{{6}}"/>
</view>
<view
class="pause-btn"
wx:if="{{audioStorage[item.value] && audioStorage[item.value].play && (!audioStorage[item.value].isWaiting || item.value != actionsPalyvalue)}}"
wx:if="{{audioStorage[item.value] && audioStorage[item.value].play && (!audioStorage[item.value].isWaiting)}}"
data-value="{{item.value}}"
data-index="{{index}}"
data-duration="{{item.duration}}"
......
......@@ -17,16 +17,16 @@
data-index="{{index}}"
bindtap="playvoice"
data-duration="{{item.duration}}"
wx:if="{{(!audioStorage[item.value] || !audioStorage[item.value].play) && (!audioStorage[item.value].isWaiting || item.value != actionsPalyvalue)}}"
wx:if="{{(!audioStorage[item.value] || !audioStorage[item.value].play) && (!audioStorage[item.value].isWaiting)}}"
>
<image class="play-btn-icon" src="{{imageRoot}}2c/common/playicon.png?{{imageVersion}}" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror="" bindload=""></image>
</view>
<view class="pause-btn load-box" wx:if="{{audioStorage[item.value].isWaiting && item.value == actionsPalyvalue}}" >
<view class="pause-btn load-box" wx:if="{{audioStorage[item.value].isWaiting}}" >
<cssloading size="{{6}}"/>
</view>
<view
class="pause-btn"
wx:if="{{audioStorage[item.value] && audioStorage[item.value].play && (!audioStorage[item.value].isWaiting || item.value != actionsPalyvalue)}}"
wx:if="{{audioStorage[item.value] && audioStorage[item.value].play && (!audioStorage[item.value].isWaiting)}}"
data-value="{{item.value}}"
data-index="{{index}}"
data-duration="{{item.duration}}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment