Commit 47252085 authored by songrui's avatar songrui

音频播放修改

parent bdc6452d
......@@ -25,7 +25,8 @@ import { showToast } from 'vant'
export default {
props: {
file: { default: () => ({}) }
file: { default: () => ({}) },
activeMediaUrl: { default: '' }
},
data() {
return {
......@@ -50,6 +51,8 @@ export default {
methods: {
init() {
this.player = new musicPlayer(this.$refs.audio)
this.player.init()
this.player.setSrc(this.file.annexUrl)
this.player.audioEl.onended = () => {
console.log('播放结束')
this.stop()
......@@ -62,19 +65,16 @@ export default {
}
if (!this.player.audioCtx) {
this.player.init()
this.player.setSrc(item.annexUrl)
}
if (this.player.duration && item.annexId === this.activeAudio.annexId) {
if (this.player.playing) {
this.stop()
} else {
this.player.audioEl.play()
this.player.playing = true
}
return
}
this.player.setSrc(item.annexUrl)
this.activeAudio = item
this.player.playing = true
this.$emit('play', item)
}
console.log('this.player', this.player)
},
stop() {
......@@ -95,6 +95,14 @@ export default {
this.player.progressChange(value)
this.player.playing = true
}
},
watch: {
activeMediaUrl(val) {
console.log('activeMediaUrl', val)
if (val !== this.file.annexUrl) {
this.stop()
}
}
}
}
</script>
......
......@@ -45,6 +45,7 @@ export default {
start(item) {
this.activeVideo = item
this.visible = true
this.$emit('play', item)
}
}
}
......
......@@ -70,7 +70,6 @@ export class musicPlayer {
this.audioEl.oncanplay = () => {
console.log('可播放')
setTimeout(() => {
this.audioEl.play()
this.getAudioSource()
}, 100)
}
......
......@@ -144,10 +144,12 @@
</div>
</div>
<div class="card mt-2" v-if="detailInfo?.publicizeType?.includes(3)">
<Mp4 :files="mp4List"/>
<Mp4 :files="mp4List" :activeMediaUrl="activeMediaUrl"
@play="e => activeMediaUrl = e.annexUrl"/>
</div>
<div class="card flex flex-col mt-2" style="row-gap: .06rem;" v-if="detailInfo?.publicizeType?.includes(2)">
<Mp3 :file="item" v-for="item in mp3List" :key="item.annexId"/>
<Mp3 :file="item" v-for="item in mp3List" :key="item.annexId" :activeMediaUrl="activeMediaUrl"
@play="e => activeMediaUrl = e.annexUrl"/>
</div>
</div>
</van-collapse-item>
......@@ -278,6 +280,7 @@ export default {
{ title: '随访科室', key: 'visitOfficeName' },
{ title: '随访医生', key: 'visitDoctorName' }
],
activeMediaUrl: ''
}
},
computed: {
......
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