Commit 5f7083d7 authored by sujie@126.com's avatar sujie@126.com

dd

parent c6c4ebbb
...@@ -152,7 +152,36 @@ Page({ ...@@ -152,7 +152,36 @@ Page({
}, },
}, },
onLoad: function(options) { // Do some initialize when page load. onLoad: function(options) { // Do some initialize when page load.
this.innerAudioContext = wx.createInnerAudioContext(); const that = this;
this.innerAudioContext = wx.getBackgroundAudioManager(); // 当前页面唯一的一个音频容器
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, cid, pagefrom,clockdate,sub} = options; const {id, tid, cid, pagefrom,clockdate,sub} = options;
this.setData({ this.setData({
tid, tid,
...@@ -1091,12 +1120,13 @@ audioStorage[value].isWaiting = true; ...@@ -1091,12 +1120,13 @@ audioStorage[value].isWaiting = true;
const {value, duration} = e.currentTarget.dataset; const {value, duration} = e.currentTarget.dataset;
const that = this; const that = this;
let audioStorage = that.data.audioStorage;
this.innerAudioContext.src = audioorigin(value); this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.title = '正在播放';
this.innerAudioContext.startTime = audioStorage[value] ? audioStorage[value].currentTime : 0;
this.innerAudioContext.obeyMuteSwitch = false; this.innerAudioContext.obeyMuteSwitch = false;
that.resetAudiosPlayStatus(); that.resetAudiosPlayStatus();
clearInterval(that.data.voiceInterval); clearInterval(that.data.voiceInterval);
let audioStorage = that.data.audioStorage;
if (!audioStorage[value]) { if (!audioStorage[value]) {
audioStorage[value] = { audioStorage[value] = {
play: true, play: true,
...@@ -1113,46 +1143,8 @@ audioStorage[value].isWaiting = true; ...@@ -1113,46 +1143,8 @@ audioStorage[value].isWaiting = true;
audioStorage[value].play = true; audioStorage[value].play = true;
} }
} }
this.innerAudioContext.onWaiting((e)=>{
const { actPalyaudioValue, audioStorage} = this.data //this.innerAudioContext.seek(audioStorage[value].currentTime)
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.play();
this.innerAudioContext.onError((e)=>{ this.innerAudioContext.onError((e)=>{
const { actPalyaudioValue, audioStorage} = this.data const { actPalyaudioValue, audioStorage} = this.data
......
...@@ -191,7 +191,35 @@ Page({ ...@@ -191,7 +191,35 @@ Page({
hasBack:false hasBack:false
}, },
onLoad: function (options) { // Do some initialize when page load. onLoad: function (options) { // Do some initialize when page load.
this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器 const that = this;
this.innerAudioContext = wx.getBackgroundAudioManager(); // 当前页面唯一的一个音频容器
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 visitor = LocalStorage.getItem('visitor'); const visitor = LocalStorage.getItem('visitor');
if (options.scene) { if (options.scene) {
let sceneQuery = scenQueryGet(options.scene); let sceneQuery = scenQueryGet(options.scene);
...@@ -1861,11 +1889,13 @@ Page({ ...@@ -1861,11 +1889,13 @@ Page({
duration duration
} = e.detail; } = e.detail;
const that = this; const that = this;
let audioStorage = that.data.audioStorage;
this.innerAudioContext.src = audioorigin(value); this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.title = '正在播放';
this.innerAudioContext.startTime = audioStorage[value] ? audioStorage[value].currentTime : 0;
this.innerAudioContext.obeyMuteSwitch = false; this.innerAudioContext.obeyMuteSwitch = false;
that.resetAudiosPlayStatus(); that.resetAudiosPlayStatus();
clearInterval(that.data.voiceInterval); clearInterval(that.data.voiceInterval);
let audioStorage = that.data.audioStorage;
if (!audioStorage[value]) { if (!audioStorage[value]) {
audioStorage[value] = { audioStorage[value] = {
play: true, play: true,
...@@ -1874,6 +1904,7 @@ Page({ ...@@ -1874,6 +1904,7 @@ Page({
isWaiting: true isWaiting: true
} }
} else { } else {
audioStorage[value].isWaiting = true
if (audioStorage[value].currentTime == audioStorage[value].duration) { if (audioStorage[value].currentTime == audioStorage[value].duration) {
audioStorage[value].currentTime = 0; audioStorage[value].currentTime = 0;
audioStorage[value].play = true; audioStorage[value].play = true;
...@@ -1881,46 +1912,8 @@ Page({ ...@@ -1881,46 +1912,8 @@ Page({
audioStorage[value].play = true; audioStorage[value].play = true;
} }
} }
this.innerAudioContext.onWaiting((e)=>{
const { actPalyaudioValue, audioStorage} = this.data // this.innerAudioContext.seek(audioStorage[value].currentTime)
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.play();
this.innerAudioContext.onError((e)=>{ this.innerAudioContext.onError((e)=>{
const audioStorage = this.data.audioStorage; const audioStorage = this.data.audioStorage;
......
...@@ -154,7 +154,7 @@ Page({ ...@@ -154,7 +154,7 @@ Page({
loginCode: '', loginCode: '',
}, },
onLoad: function (options) { // Do some initialize when page load. onLoad: function (options) { // Do some initialize when page load.
this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器 this.innerAudioContext = wx.getBackgroundAudioManager(); // 当前页面唯一的一个音频容器
this.innerAudioContext.onWaiting((e)=>{ this.innerAudioContext.onWaiting((e)=>{
const { actPalyaudioValue, audioStorage} = this.data const { actPalyaudioValue, audioStorage} = this.data
if(audioStorage[actPalyaudioValue].isWaiting){ if(audioStorage[actPalyaudioValue].isWaiting){
...@@ -174,15 +174,26 @@ Page({ ...@@ -174,15 +174,26 @@ Page({
this.innerAudioContext.onTimeUpdate((e) => { this.innerAudioContext.onTimeUpdate((e) => {
const { actPalyaudioValue, audioStorage} = this.data const { actPalyaudioValue, audioStorage} = this.data
if (audioStorage[actPalyaudioValue].isWaiting) { if (audioStorage[actPalyaudioValue].isWaiting) {
//this.innerAudioContext.seek(audioStorage[actPalyaudioValue].currentTime || 0)
clearInterval(this.data.voiceInterval); clearInterval(this.data.voiceInterval);
this.voiceIntervalPlay(actPalyaudioValue); this.voiceIntervalPlay(actPalyaudioValue);
audioStorage[actPalyaudioValue].isWaiting = false audioStorage[actPalyaudioValue].isWaiting = false
this.setData({ this.setData({
[`audioStorage.${actPalyaudioValue}`] : audioStorage[actPalyaudioValue], [`audioStorage.${actPalyaudioValue}`] : audioStorage[actPalyaudioValue],
}) })
} }
}) })
// this.innerAudioContext.onPlay(()=>{
// const { actPalyaudioValue, audioStorage} = this.data;
// console.log(audioStorage[actPalyaudioValue], 'audioStorage[actPalyaudioValue]')
// if(audioStorage[actPalyaudioValue]){
// this.innerAudioContext.seek(audioStorage[actPalyaudioValue].currentTime || 0)
// }
// this.data.audioStorage[actPalyaudioValue].isFirst = true;
// })
if (options.scene) { if (options.scene) {
let sceneQuery = scenQueryGet(options.scene); let sceneQuery = scenQueryGet(options.scene);
const { const {
...@@ -1391,11 +1402,15 @@ Page({ ...@@ -1391,11 +1402,15 @@ Page({
duration duration
} = e.detail; } = e.detail;
const that = this; const that = this;
let audioStorage = that.data.audioStorage;
this.innerAudioContext.src = audioorigin(value); this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.title = '正在播放';
this.innerAudioContext.startTime = audioStorage[value] ? audioStorage[value].currentTime : 0;
this.innerAudioContext.obeyMuteSwitch = false; this.innerAudioContext.obeyMuteSwitch = false;
that.resetAudiosPlayStatus(); that.resetAudiosPlayStatus();
clearInterval(that.data.voiceInterval); clearInterval(that.data.voiceInterval);
let audioStorage = that.data.audioStorage;
if (!audioStorage[value]) { if (!audioStorage[value]) {
audioStorage[value] = { audioStorage[value] = {
play: true, play: true,
...@@ -1411,11 +1426,9 @@ Page({ ...@@ -1411,11 +1426,9 @@ Page({
} else { } else {
audioStorage[value].play = true; audioStorage[value].play = true;
} }
} }
this.innerAudioContext.seek(audioStorage[value].currentTime)
this.innerAudioContext.play(); this.innerAudioContext.play();
this.innerAudioContext.onError((e)=>{ this.innerAudioContext.onError((e)=>{
const { actPalyaudioValue, audioStorage} = this.data const { actPalyaudioValue, audioStorage} = this.data
audioStorage[actPalyaudioValue].isWaiting = false; audioStorage[actPalyaudioValue].isWaiting = false;
......
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