Added the logic for the music change and autoplay

pull/46/head
Nikan Dalvand 2019-08-02 20:45:08 +04:30
parent 52179c6e45
commit 000f5584e6
1 changed files with 14 additions and 3 deletions

View File

@ -49,7 +49,6 @@ import color from 'dominant-color'
import { formatSeconds } from '../utility/DateTime' import { formatSeconds } from '../utility/DateTime'
import IconButton from '../components/IconButton' import IconButton from '../components/IconButton'
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters } from 'vuex'
export default { export default {
name: 'PlayerBar', name: 'PlayerBar',
components: { IconButton }, components: { IconButton },
@ -98,11 +97,17 @@ export default {
] ]
}) })
this.wavesurfer.load(this.playerQueue[this.currentlyPlaying].stream) this.wavesurfer.load(this.playerQueue[this.currentlyPlaying].stream)
let readyCounter = 0
this.wavesurfer.on('ready', () => { this.wavesurfer.on('ready', () => {
console.log('ready')
readyCounter += 1
this.duration = formatSeconds(this.getDuration()) this.duration = formatSeconds(this.getDuration())
this.wavesurfer.container.style['height'] = '100%'
let map = this.wavesurfer.minimap.drawer.container let map = this.wavesurfer.minimap.drawer.container
this.wavesurfer.container.style['height'] = '100%'
map.style['height'] = '100%' map.style['height'] = '100%'
if (readyCounter > 0) {
this.play()
}
}) })
let currentWidth = 0 let currentWidth = 0
let hoverStatus = false let hoverStatus = false
@ -191,9 +196,11 @@ export default {
}, },
pause () { pause () {
this.wavesurfer.pause() this.wavesurfer.pause()
this.playingStatus = this.isPlaying()
}, },
stop () { stop () {
this.wavesurfer.stop() this.wavesurfer.stop()
this.playingStatus = this.isPlaying()
}, },
toggleMute () { toggleMute () {
this.wavesurfer.toggleMute() this.wavesurfer.toggleMute()
@ -217,7 +224,11 @@ export default {
return this.wavesurfer.getDuration() return this.wavesurfer.getDuration()
}, },
togglePlay () { togglePlay () {
this.wavesurfer.playPause() if (this.isPlaying()) {
this.pause()
} else {
this.play()
}
this.playingStatus = this.isPlaying() this.playingStatus = this.isPlaying()
}, },
toggleFavorite () { toggleFavorite () {