|
@@ -74,7 +74,7 @@ import {apiVoiceList,apiVoiceSectionList,apiVoicePlayRecord,apiVoiceDel} from '@
|
|
|
import {apiGetSceneToParams} from '@/api/common'
|
|
|
import noAuth from './components/noAuth.vue'
|
|
|
const moment=require('@/utils/moment-with-locales.min')
|
|
|
-// let innerAudioContext = uni.createInnerAudioContext();//播放音频实例
|
|
|
+let innerAudioContext = uni.createInnerAudioContext();//播放音频实例
|
|
|
export default {
|
|
|
components:{
|
|
|
noAuth
|
|
@@ -91,7 +91,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- innerAudioContext:uni.createInnerAudioContext(),//播放音频实例
|
|
|
+ // innerAudioContext:null,//播放音频实例
|
|
|
list:[],
|
|
|
page:1,
|
|
|
pageSize:20,
|
|
@@ -120,7 +120,6 @@ export default {
|
|
|
onLoad(options){
|
|
|
this.init(options)
|
|
|
this.getOptionsList()
|
|
|
- this.listenAudio()
|
|
|
this.addListenVoiceSuccess()
|
|
|
},
|
|
|
onShow(){
|
|
@@ -128,6 +127,8 @@ export default {
|
|
|
if(!this.isAuth){
|
|
|
this.getVoiceList()
|
|
|
}
|
|
|
+ // this.innerAudioContext=uni.createInnerAudioContext()
|
|
|
+ this.listenAudio()
|
|
|
},
|
|
|
onUnload(){
|
|
|
uni.$off('addVoiceSuccess')
|
|
@@ -293,30 +294,27 @@ export default {
|
|
|
},
|
|
|
|
|
|
handlePlay(item){
|
|
|
- const innerAudioContext=this.innerAudioContext
|
|
|
- //没有初始化时
|
|
|
- if(this.temAudio.id==0||this.temAudio.id!=item.BroadcastId){
|
|
|
- this.listenAudio()
|
|
|
+ if(this.temAudio.id==item.BroadcastId){
|
|
|
+ if(innerAudioContext.paused){
|
|
|
+ innerAudioContext.play()
|
|
|
+ }else{
|
|
|
+ innerAudioContext.pause()
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(!innerAudioContext.paused){
|
|
|
+ innerAudioContext.stop()
|
|
|
+ }
|
|
|
this.temAudio.id=item.BroadcastId
|
|
|
this.temAudio.duration=item.VoicePlaySeconds
|
|
|
this.temAudio.curTime=item.VoicePlaySeconds
|
|
|
innerAudioContext.src=item.VoiceUrl
|
|
|
innerAudioContext.play()
|
|
|
- this.temAudio.paused=false
|
|
|
this.handleVoicePlayRecord(item)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- if(innerAudioContext.paused){
|
|
|
- innerAudioContext.play()
|
|
|
- }else{
|
|
|
- innerAudioContext.pause()
|
|
|
}
|
|
|
},
|
|
|
|
|
|
//音频播放事件
|
|
|
listenAudio(){
|
|
|
- const innerAudioContext=this.innerAudioContext
|
|
|
innerAudioContext.onPlay(()=>{
|
|
|
console.log('开始播放录音');
|
|
|
this.temAudio.paused=false
|
|
@@ -325,21 +323,18 @@ export default {
|
|
|
console.log('录音播放暂停');
|
|
|
this.temAudio.paused=true
|
|
|
})
|
|
|
- innerAudioContext.onStop(()=>{
|
|
|
- console.log('录音播放停止');
|
|
|
- this.temAudio.paused=true
|
|
|
- setTimeout(() => {
|
|
|
- this.temAudio.id=0
|
|
|
- }, 100);
|
|
|
- innerAudioContext.src=''
|
|
|
- })
|
|
|
+ // innerAudioContext.onStop(()=>{
|
|
|
+ // console.log('录音播放停止');
|
|
|
+ // this.temAudio.paused=true
|
|
|
+ // // setTimeout(() => {
|
|
|
+ // this.temAudio.id=0
|
|
|
+ // // }, 100);
|
|
|
+ // })
|
|
|
innerAudioContext.onEnded(()=>{
|
|
|
console.log('录音播放自然结束');
|
|
|
- setTimeout(() => {
|
|
|
- this.temAudio.paused=true
|
|
|
- this.temAudio.id=0
|
|
|
- innerAudioContext.src=''
|
|
|
- }, 100);
|
|
|
+ this.temAudio.paused=true
|
|
|
+ this.temAudio.id=0
|
|
|
+
|
|
|
})
|
|
|
innerAudioContext.onTimeUpdate(()=>{
|
|
|
// console.log('时间更新');
|