如何停止在Vue-Wavesurfer中重复播放音乐?

时间:2019-04-14 18:19:17

标签: vue.js audio vuex nuxt.js wavesurfer.js

我正试图停止播放音频,但这只是工作一次。

Player.vue 组件中,我停止播放音频:

 stop() {
        this.audio.currentTime = 0;
        this.audio.pause();
        this.isPlaying = false;

        this.$store.commit('stopStatus', this.currentSong.id);
        this.$store.commit('playingStatus', false);
      },

Vuex

export const state = () => ({
  stop: false
});

export const mutations = {
  stopStatus(state, val) {
    state.stop = val;
  },
};

export const getters = {
  getStopStatus: state => state.stop,
};

Index.vue 在已安装的挂钩中:

      this.$store.watch(
        state => {
          return this.$store.getters.getStopStatus;
        },
        val => {
          if (val === this.song.id) {
            this.WaveSurfer.stop();
            this.WaveSurfer.setCurrentTime(0);
            this.icon = false;
          }
        }
      );

0 个答案:

没有答案