Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let const Store = {
- states : {
- audioCurrentTime : 0,
- audio : null
- manualSet : false,
- },
- getters : {
- getAudioOBj : state => state.audio
- },
- mutations : {
- setAudioTime(state, time){
- state.manualSet = true;
- state.audio.currentTime = parseFloat(time)
- },
- setTracks : (state, payload) {
- if(state.audio == null){
- state.audio = new Audio(payload.url);
- state.audio.addEventListener('timeupdate', function(){
- if(state.manualSet){
- state.manualSet = false;
- /* return 0 when it called from $.store.commit('setAudioTime', 100) */
- console.log(this.currentTime)
- }
- state.audioCurrentTime = this.currentTime;
- })
- }else{
- state.audio.load(payload.url);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement