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.
 
 
 
 

67 lines
1.3 KiB

  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. isBgPlay: false, // 是否后台播放
  8. messageObj: {}, //
  9. },
  10. mutations: {
  11. // 日报详情
  12. setMessageObj(state, obj) {
  13. state.messageObj = obj
  14. },
  15. createAudio(state) {
  16. state.bgAudioMannager = uni.getBackgroundAudioManager();
  17. },
  18. setSeekAudio(state, t) {
  19. state.bgAudioMannager.seek(t)
  20. },
  21. // 加载音频监听方法
  22. initAudioMethod(state, obj) {
  23. state.bgAudioMannager.onCanplay(() => {
  24. state.bgAudioMannager.currentTime = obj.currentTime
  25. });
  26. state.bgAudioMannager.onStop(() => {
  27. console.log('停止播放');
  28. });
  29. state.bgAudioMannager.onPause(() => {
  30. console.log('暂停播放');
  31. });
  32. state.bgAudioMannager.onEnded(() => {
  33. //初始化 需要的参数
  34. console.log('自然播放结束事件');
  35. });
  36. state.bgAudioMannager.onError((res) => {
  37. console.log(res.errMsg);
  38. console.log(res.errCode);
  39. });
  40. },
  41. // 停止全局音频播放
  42. stopAduio(state) {
  43. if (state.bgAudioMannager != null) {
  44. if (state.bgAudioMannager.src != '') {
  45. state.bgAudioMannager.src = ''
  46. }
  47. }
  48. },
  49. // 设置播放状态
  50. setIsBgPlay(state, value) {
  51. state.isBgPlay = value
  52. }
  53. },
  54. })