I want to have audio player in Vuex store to use its data for output to custom audio player in a Vue components.
In Vuex store there is a state property aplayer
that plays music.
store.js
code:
state: {
aplayer: new Audio()
},
getters: {
getCurrentTime: state => state.aplayer.currentTime
}
In the component I want to display aplayer.currentTime
the current song. I'm trying to get it by using the getter getPlayer
in a computed properties.
components.vue
code:
getCurrentTime() {
return this.$store.getters.getCurrentTime;
}
But when output to the template, the current time freezes to 0. However, when I press "pause", the current time is displayed correctly.
Please help.