import {ref} from "vue" import { audioPlayer, useAudioCache, } from "./useAudio.js"; export function useYinBiaoAutoPlay () { const AudioP = new audioPlayer(); const { cacheAudio, } = useAudioCache(); const current = ref(0); const list = ref([]); let code = null; const isAutoPlaying = ref(false); async function handlePlay() { isAutoPlaying.value = true; code = new Date().getTime(); const activeYin = { url: list.value[current.value].yinpin, code } const cachedPath = await cacheAudio(activeYin.url); if (cachedPath && cachedPath.includes('.mp3')) { AudioP.play(cachedPath, code); } else { uni.showToast({ title: '音频加载失败', icon: 'none' }); isAutoPlaying.value = false; } } function initListen() { uni.$on('danci-audio-ended', (mCode) => { if (code !== mCode) { isAutoPlaying.value = false; return; } if (current.value