Updated playerbar and player state

pull/44/head
Nikan Dalvand 2019-08-01 23:59:05 +04:30
parent b9ff59c712
commit 341b284d66
2 changed files with 13 additions and 23 deletions

View File

@ -1,10 +1,10 @@
<template>
<section>
<section class="player">
<img @load="onArtworkLoad" class="artwork" :src="playerQueue[this.currentlyPlaying].artwork" />
<img @load="onArtworkLoad" class="artwork" :src="currentlyPlaying.artwork" />
<div>
<p class="title">{{playerQueue[this.currentlyPlaying].title}}</p>
<p class="artist">{{playerQueue[this.currentlyPlaying].artist}}</p>
<p class="title">{{currentlyPlaying.title}}</p>
<p class="artist">{{currentlyPlaying.artist}}</p>
</div>
<div class="visualizer">
<div id="visualizer"></div>
@ -61,7 +61,7 @@ export default {
isFullscreen: false
}
},
computed: mapGetters(['fullscreenStatus', 'currentlyPlaying', 'playerQueue']),
computed: mapGetters(['fullscreenStatus', 'currentlyPlaying']),
mounted () {
let progress = this.$el.getElementsByClassName('progress')[0]
this.wavesurfer = WaveSurfer.create({
@ -90,7 +90,7 @@ export default {
})
]
})
this.wavesurfer.load(this.playerQueue[this.currentlyPlaying].stream)
this.wavesurfer.load(this.currentlyPlaying.stream)
this.wavesurfer.on('ready', () => {
this.duration = formatSeconds(this.getDuration())
this.wavesurfer.container.style['height'] = '100%'

View File

@ -1,38 +1,28 @@
const state = {
fullscreen_mode: false,
currently_playing: 0,
queue: [
{
id: 8,
title: 'Yellow',
artist: 'Rich Brian',
artwork: '/static/demo/yellow.jpeg',
stream: '/static/demo/music.mp3'
}
]
currently_playing: {
id: 8,
title: 'Yellow',
artist: 'Rich Brian',
artwork: '/static/demo/yellow.jpeg',
stream: '/static/demo/music.mp3'
}
}
const getters = {
fullscreenStatus: (state) => state.fullscreen_mode,
currentlyPlaying: (state) => state.currently_playing,
playerQueue: (state) => state.queue
currentlyPlaying: (state) => state.currently_playing
}
const mutations = {
TOGGLE_FULLSCREEN (state) {
state.fullscreen_mode = !state.fullscreen_mode
},
PLAY_QUEUE_ITEM (state, index) {
state.currently_playing = index
}
}
const actions = {
toggleFullscreenStatus ({ commit }) {
commit('TOGGLE_FULLSCREEN')
},
playQueueItem ({ commit }, index) {
commit('PLAY_QUEUE_ITEM', index)
}
}