<template>
	<view></view>
</template>

<script setup>
	import {
		useAudio
	} from './useAudio';
	let historyData = null;
	const {
		handlePlay,
		handleStop,
		innerAudioContext
	} = useAudio();
	// 播放
	uni.$on('do-yy-audio-play', (data) => {
    if (historyData) {
      if (historyData.stId != data.stId && historyData.index != data.index) {
        // 播放中切换其他音频时发出事件
        uni.$emit('reset-playing-status', historyData);
        historyData = null
        return;
      }

      if (historyData.stId != data.stId ) {
        // 播放中切换其他音频时发出事件
        uni.$emit('reset-playing-status', historyData);
        historyData = null
        return;
      }
    }

		handlePlay(data)
    historyData = data;
  })
	// 暂停
	uni.$on('do-yy-audio-stop', () => {
		handleStop()
	})
	// 销毁
	uni.$on('destory-stop', () => {
		handleStop()
	})
</script>

<style>
</style>