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.
 
 
 

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