|
- import Vue from 'vue';
- import Vuex from 'vuex';
-
- Vue.use(Vuex)
-
- export default new Vuex.Store({
- state: {
- bgAudioMannager: null,
- },
-
- mutations: {
- createAudio(state) {
- state.bgAudioManager = uni.getBackgroundAudioManager();
- },
-
- // 设置全局播放的音频
- setAudio(state, obj) {
- state.bgAudioManager.title = '录音音频';
- state.bgAudioManager.src = obj.src
- state.bgAudioManager.startTime = obj.currentTime
- },
-
- // 初始化全局播放音频
- initBgAudio(state) {
- state.bgAudioMannager.onPlay(() => {
- console.log('开始播放');
- });
- state.bgAudioMannager.onStop(() => {
- console.log('停止播放');
- });
-
- state.bgAudioMannager.onPause(() => {
- console.log('暂停播放');
- });
- state.bgAudioMannager.onEnded(() => {
- //初始化 需要的参数
- console.log('自然播放结束事件');
- });
- state.bgAudioMannager.onError((res) => {
- console.log(res.errMsg);
- console.log(res.errCode);
- });
- state.bgAudioMannager.pause()
- },
-
- // 停止全局音频播放
- stopAduio(state) {
- if (state.bgAudioManager && state.bgAudioManager.src) {
- state.bgAudioManager.stop()
- state.bgAudioManager.src = ''
- }
- },
- },
-
- action: {
-
- }
- })
|