AI销管
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.2 KiB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import Vue from 'vue';
  2. import Vuex from 'vuex';
  3. Vue.use(Vuex)
  4. export default new Vuex.Store({
  5. state: {
  6. bgAudioMannager: null,
  7. },
  8. mutations: {
  9. createAudio(state) {
  10. state.bgAudioManager = uni.getBackgroundAudioManager();
  11. },
  12. // 设置全局播放的音频
  13. setAudio(state, obj) {
  14. state.bgAudioManager.title = '录音音频';
  15. state.bgAudioManager.src = obj.src
  16. state.bgAudioManager.startTime = obj.currentTime
  17. },
  18. // 初始化全局播放音频
  19. initBgAudio(state) {
  20. state.bgAudioMannager.onPlay(() => {
  21. console.log('开始播放');
  22. });
  23. state.bgAudioMannager.onStop(() => {
  24. console.log('停止播放');
  25. });
  26. state.bgAudioMannager.onPause(() => {
  27. console.log('暂停播放');
  28. });
  29. state.bgAudioMannager.onEnded(() => {
  30. //初始化 需要的参数
  31. console.log('自然播放结束事件');
  32. });
  33. state.bgAudioMannager.onError((res) => {
  34. console.log(res.errMsg);
  35. console.log(res.errCode);
  36. });
  37. state.bgAudioMannager.pause()
  38. },
  39. // 停止全局音频播放
  40. stopAduio(state) {
  41. if (state.bgAudioManager && state.bgAudioManager.src) {
  42. state.bgAudioManager.stop()
  43. state.bgAudioManager.src = ''
  44. }
  45. },
  46. },
  47. action: {
  48. }
  49. })