Merge pull request #46 from nikandlv/development

Playerbar wave update
master
Nikan Dalvand 2019-08-02 20:52:43 +04:30 committed by GitHub
commit 693f5dc65d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 12 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 },
@ -65,6 +64,9 @@ export default {
mounted () { mounted () {
this.drawVisualizer() this.drawVisualizer()
}, },
updated () {
this.wavesurfer.load(this.playerQueue[this.currentlyPlaying].stream)
},
methods: { methods: {
drawVisualizer () { drawVisualizer () {
let progress = this.$el.getElementsByClassName('progress')[0] let progress = this.$el.getElementsByClassName('progress')[0]
@ -95,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
@ -168,21 +176,31 @@ export default {
}) })
}, },
playNext () { playNext () {
this.wavesurfer.container.style['height'] = '0%'
let map = this.wavesurfer.minimap.drawer.container
map.style['height'] = '0%'
window.setTimeout(() => {
this.playQueueItem(this.currentlyPlaying + 1) this.playQueueItem(this.currentlyPlaying + 1)
this.wavesurfer.load(this.playerQueue[this.currentlyPlaying].stream) }, 500)
}, },
playPrevious () { playPrevious () {
this.wavesurfer.container.style['height'] = '0%'
let map = this.wavesurfer.minimap.drawer.container
map.style['height'] = '0%'
window.setTimeout(() => {
this.playQueueItem(this.currentlyPlaying - 1) this.playQueueItem(this.currentlyPlaying - 1)
this.wavesurfer.load(this.playerQueue[this.currentlyPlaying].stream) }, 500)
}, },
play () { play () {
this.wavesurfer.play() this.wavesurfer.play()
}, },
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()
@ -206,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 () {
@ -249,7 +271,7 @@ section.player
top: 0 top: 0
bottom: 0 bottom: 0
margin: auto margin: auto
transition: height 500ms ease ease transition: height 500ms ease
height: 0px height: 0px
width: 100% width: 100%
z-index: z-index:
@ -272,7 +294,7 @@ section.fullscreen
background-color: white background-color: white
z-index: 1400 z-index: 1400
transition: transform 500ms ease-out transition: transform 500ms ease-out
transform: translate3d(0,+100vh,0) transform: translate3d(0,+100%,0)
&.active &.active
transform: translate3d(0,0vh,0) transform: translate3d(0,0%,0)
</style> </style>

View File

@ -20,8 +20,8 @@ const state = {
id: 8, id: 8,
title: 'Ali sorena', title: 'Ali sorena',
artist: 'Negar', artist: 'Negar',
artwork: 'http://sakhamusic.ir/wp-content/uploads/2016/03/Ali-Sorena-%E2%80%93-Negar.jpg', artwork: '/static/demo/negar.jpg',
stream: 'http://dl.sakhamusic.ir/94/esfand/09/03%20Negar%20(Prod.%20Ehsan%20Ziya)_2.mp3' stream: '/static/demo/negar.mp3'
} }
] ]
} }

BIN
static/demo/negar.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
static/demo/negar.mp3 Normal file

Binary file not shown.