mtaRadio.vue 928 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <view></view>
  3. </template>
  4. <script setup>
  5. import {
  6. useAudio
  7. } from './useAudio';
  8. let historyData = null;
  9. const {
  10. handlePlay,
  11. handleStop,
  12. innerAudioContext
  13. } = useAudio();
  14. // 播放
  15. uni.$on('do-yy-audio-play', (data) => {
  16. if (historyData) {
  17. if (historyData.stId != data.stId && historyData.index != data.index) {
  18. // 播放中切换其他音频时发出事件
  19. uni.$emit('reset-playing-status', historyData);
  20. historyData = null
  21. return;
  22. }
  23. if (historyData.stId != data.stId ) {
  24. // 播放中切换其他音频时发出事件
  25. uni.$emit('reset-playing-status', historyData);
  26. historyData = null
  27. return;
  28. }
  29. }
  30. handlePlay(data)
  31. historyData = data;
  32. })
  33. // 暂停
  34. uni.$on('do-yy-audio-stop', () => {
  35. handleStop()
  36. })
  37. // 销毁
  38. uni.$on('destory-stop', () => {
  39. handleStop()
  40. })
  41. </script>
  42. <style>
  43. </style>