| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * 音频播放 mixin
- * 代理 audioStore,实现跨页面音频持久化播放
- * 退出页面后音频继续播放,再次进入页面恢复播放状态
- */
- import { useAudioStore } from '@/stores/audio'
- export default {
- computed: {
- _audioStore() {
- return useAudioStore()
- },
- audiolist() {
- return this._audioStore.audiolist
- },
- curAudioInx: {
- get() { return this._audioStore.curAudioInx },
- set(val) { this._audioStore.curAudioInx = val }
- },
- totalTime() {
- return this._audioStore.totalTime
- },
- currentTime() {
- return this._audioStore.currentTime
- },
- ispause() {
- return this._audioStore.ispause
- },
- isShowDrawer3: {
- get() { return this._audioStore.isShowDrawer3 },
- set(val) { this._audioStore.isShowDrawer3 = val }
- }
- },
- methods: {
- initAudio() {
- this._audioStore.initAudio()
- },
- formatTime(totalSeconds) {
- return this._audioStore.formatTime(totalSeconds)
- },
- changeAudio(url, inx) {
- this._audioStore.changeAudio(url, inx)
- },
- playAudio() {
- this._audioStore.playAudio()
- },
- /** 供 ble-mixin 模式切换时调用 */
- _stopAudioOnModeChange() {
- this._audioStore.stopAudio()
- },
- /** 页面离开时解绑事件(音频继续播放) */
- detachAudio() {
- this._audioStore.detachEvents()
- },
- /** 彻底销毁(一般不调用,仅供极端场景) */
- destroyAudio() {
- this._audioStore.destroyAudio()
- }
- }
- }
|