Merge pull request #41 from nikandlv/development

Added and consumed player currently playing state
master
Nikan Dalvand 2019-07-31 23:57:30 +04:30 committed by GitHub
commit 78649ee0c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

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

View File

@ -1,9 +1,17 @@
const state = { const state = {
fullscreen_mode: false fullscreen_mode: false,
currently_playing: {
id: 8,
title: 'Yellow',
artist: 'Rich Brian',
artwork: '/static/demo/yellow.jpeg',
stream: '/static/demo/music.mp3'
}
} }
const getters = { const getters = {
fullscreenStatus: (state) => state.fullscreen_mode fullscreenStatus: (state) => state.fullscreen_mode,
currentlyPlaying: (state) => state.currently_playing
} }
const mutations = { const mutations = {