Commit 6f5a904c authored by sujie@126.com's avatar sujie@126.com

dd

parent beb8e1ec
......@@ -22,6 +22,7 @@ import {
} from '../../../service/business/common.js';
var app = getApp();
Page({
mixins: [require('../../../mixins/myMins/audioCallback')],
data: {
maxLength: 500,
maxImgCount: 9,
......@@ -117,47 +118,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,
})
}
})
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,
})
});
const {
id,
tid,
......@@ -603,163 +563,6 @@ Page({
duration
}); // 页面向组件传递参数
},
// 跟录音相关的操作
// 跟录音相关的操作
// 播放录音的相关操作
// 格式是以录音名字为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 {
audioStorage[value].isWaiting = true
if (audioStorage[value].currentTime == audioStorage[value].duration) {
audioStorage[value].currentTime = 0;
audioStorage[value].play = true;
} else {
audioStorage[value].play = true;
}
}
// 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,
// })
// }
// })
console.log(audioStorage[value].currentTime, 'audioStorage[value].currentTime');
this.innerAudioContext.seek(audioStorage[value].currentTime)
this.innerAudioContext.play();
//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,
})
},
// 跟录音相关的操作
remindswitch() {
if (Number(this.data.params.push_status) == 2) {
......
......@@ -126,7 +126,6 @@ Page({
},
},
onLoad: function(options) { // Do some initialize when page load.
this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器
const {id, tid,sid} = options;
this.setData({
id,
......@@ -158,16 +157,10 @@ 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.setData({
audioStorage: {}
})
clearInterval(this.data.voiceInterval);
},
onPullDownRefresh: function() { // Do something when pull down.
this.setData({
......@@ -738,168 +731,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;
......
......@@ -23,6 +23,22 @@ module.exports = {
})
}, 5000)
})
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,
})
})
this.innerAudioContext.onTimeUpdate((e) => {
const {
actPalyaudioValue,
......@@ -72,55 +88,45 @@ module.exports = {
})
},
playvoice(e) {
const value = e.detail.value || e.currentTarget.dataset.value || 0;
const duration = e.detail.duration || e.currentTarget.dataset.duration || 0;
const that = this;
let audioStorage = that.data.audioStorage;
this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.title = '正在播放';
this.innerAudioContext.startTime = audioStorage[value] ? audioStorage[value].currentTime : 0;
this.innerAudioContext.obeyMuteSwitch = false;
that.resetAudiosPlayStatus();
clearInterval(that.data.voiceInterval);
if (!audioStorage[value]) {
audioStorage[value] = {
play: true,
currentTime: 0,
duration,
isWaiting: true
}
} else {
audioStorage[value].isWaiting = true
if (audioStorage[value].currentTime == audioStorage[value].duration) {
audioStorage[value].currentTime = 0;
audioStorage[value].play = true;
// clearTimeout(this.setplayvoice)
// this.setplayvoice = setTimeout(()=>{
const value = e.detail.value || e.currentTarget.dataset.value || 0;
const duration = e.detail.duration || e.currentTarget.dataset.duration || 0;
const that = this;
let audioStorage = that.data.audioStorage;
this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.title = '正在播放';
this.innerAudioContext.startTime = audioStorage[value] ? audioStorage[value].currentTime : 0;
this.innerAudioContext.obeyMuteSwitch = false;
that.resetAudiosPlayStatus();
clearInterval(that.data.voiceInterval);
if (!audioStorage[value]) {
audioStorage[value] = {
play: true,
currentTime: 0,
duration,
}
} else {
audioStorage[value].play = true;
if (audioStorage[value].currentTime == audioStorage[value].duration) {
audioStorage[value].currentTime = 0;
audioStorage[value].play = true;
} else {
audioStorage[value].play = true;
}
}
}
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,
actPalyaudioValue: value
})
})
that.setData({
audioStorage,
actPalyaudioValue: value
})
audioStorage[value].isWaiting = true
this.innerAudioContext.play();
// })
},
pausevoice(e) {
const value = e.detail.value || e.currentTarget.dataset.value || 0;
......@@ -145,32 +151,56 @@ module.exports = {
}
} else {
audioStorage[value].currentTime = slide;
audioStorage[value].isWaiting = true;
}
this.innerAudioContext.seek(slide);
this.setData({
audioStorage,
})
clearTimeout(this.Timeout)
this.Timeout=setTimeout(()=>{
console.log(value, audioStorage[value])
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则启用定时器 播放按钮状态不需要改
this.data.audioStorage[value].isWaiting = true;
setTimeout(()=>{
this.data.audioStorage[value].isWaiting = false;
},2000)
console.log('拖动播放',slide)
if(slide >= audioStorage[value].duration){
console.log('拖到低了',slide)
return;
}
this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.title = '正在播放';
this.innerAudioContext.startTime = slide || audioStorage[value].currentTime || 0;
this.innerAudioContext.play();
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
})
},
slidestart(e) {
const value = e.detail.value || e.currentTarget.dataset.value || 0;
const slide = e.detail.slide || e.currentTarget.dataset.slide || 0;
let audioStorage = this.data.audioStorage;
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则先暂停音乐盒计时器 播放按钮状态不需要改
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
},
slideend(e) {
const value = e.detail.value || e.currentTarget.dataset.value || 0;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则启用定时器 播放按钮状态不需要改
// clearInterval(this.data.voiceInterval);
this.innerAudioContext.play();
this.voiceIntervalPlay(value);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
// const value = e.detail.value || e.currentTarget.dataset.value || 0;
// let audioStorage = this.data.audioStorage;
// this.data.audioStorage[value].isWaiting = true;
// if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则启用定时器 播放按钮状态不需要改
// console.log('拖动播放')
// this.innerAudioContext.src = audioorigin(value);
// this.innerAudioContext.title = '正在播放';
// this.innerAudioContext.startTime = audioStorage[value] ? audioStorage[value].currentTime : 0;
// this.innerAudioContext.play();
// } else { // 如果当前不是播放状态 则该干嘛干嘛
// }
},
resetAudiosPlayStatus() { // 点击一个录音的时候把其他的录音状态改成暂停状态
let audioStorage = this.data.audioStorage;
......@@ -193,4 +223,4 @@ module.exports = {
audioStorage,
})
},
}
\ No newline at end of file
}
......@@ -229,7 +229,7 @@
</scroll-view>
</view>
<canvasdrawer painting="{{painting}}" bind:getImage="eventGetImage"/>
<view class="" wx:if="{{themeDetail.school_id == activtySchoolInfo.sid}}">
<view class="" wx:if="{{themeDetail.school_id == activtySchoolInfo.sid}}">
<activity-bar
classid="{{activtySchoolInfo.id}}"
sid="{{activtySchoolInfo.sid}}"
......
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