2018-08-11 01:47:10 -04:00
|
|
|
<template>
|
2018-11-09 23:16:25 -05:00
|
|
|
<section class="hero fd-is-fullheight">
|
|
|
|
<div class="hero-head fd-has-padding-left-right">
|
|
|
|
<div class="container has-text-centered fd-has-margin-top">
|
|
|
|
<h1 class="title is-4">
|
2018-08-11 01:47:10 -04:00
|
|
|
{{ now_playing.title }}
|
|
|
|
</h1>
|
2018-11-09 23:16:25 -05:00
|
|
|
<h2 class="title is-6">
|
2018-08-11 01:47:10 -04:00
|
|
|
{{ now_playing.artist }}
|
|
|
|
</h2>
|
2018-11-09 23:16:25 -05:00
|
|
|
<h3 class="subtitle is-6">
|
2018-08-11 01:47:10 -04:00
|
|
|
{{ now_playing.album }}
|
|
|
|
</h3>
|
2018-11-09 23:16:25 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="hero-body fd-is-fullheight-body has-text-centered" v-show="artwork_visible">
|
|
|
|
<img :src="artwork_url" class="fd-has-shadow fd-image-fullheight" @load="artwork_loaded" @error="artwork_error">
|
|
|
|
</div>
|
|
|
|
<div class="hero-foot fd-has-padding-left-right">
|
|
|
|
<div class="container has-text-centered fd-has-margin-bottom">
|
2018-08-11 01:47:10 -04:00
|
|
|
<p class="control has-text-centered fd-progress-now-playing">
|
|
|
|
<range-slider
|
|
|
|
class="seek-slider fd-has-action"
|
|
|
|
min="0"
|
|
|
|
:max="state.item_length_ms"
|
|
|
|
:value="item_progress_ms"
|
|
|
|
:disabled="state.state === 'stop'"
|
|
|
|
step="1000"
|
|
|
|
@change="seek" >
|
|
|
|
</range-slider>
|
|
|
|
</p>
|
|
|
|
<p class="content">
|
|
|
|
<span>{{ item_progress_ms | duration }} / {{ now_playing.length_ms | duration }}</span>
|
|
|
|
</p>
|
2018-11-09 23:16:25 -05:00
|
|
|
<div class="buttons has-addons is-centered">
|
2018-08-11 01:47:10 -04:00
|
|
|
<player-button-previous class="button is-medium"></player-button-previous>
|
|
|
|
<player-button-play-pause class="button is-medium" icon_style="mdi-36px"></player-button-play-pause>
|
|
|
|
<player-button-next class="button is-medium"></player-button-next>
|
|
|
|
<player-button-repeat class="button is-medium is-light"></player-button-repeat>
|
|
|
|
<player-button-shuffle class="button is-medium is-light"></player-button-shuffle>
|
|
|
|
<player-button-consume class="button is-medium is-light"></player-button-consume>
|
2018-11-09 23:16:25 -05:00
|
|
|
</div>
|
2018-08-11 01:47:10 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import PlayerButtonPlayPause from '@/components/PlayerButtonPlayPause'
|
|
|
|
import PlayerButtonNext from '@/components/PlayerButtonNext'
|
|
|
|
import PlayerButtonPrevious from '@/components/PlayerButtonPrevious'
|
|
|
|
import PlayerButtonShuffle from '@/components/PlayerButtonShuffle'
|
|
|
|
import PlayerButtonConsume from '@/components/PlayerButtonConsume'
|
|
|
|
import PlayerButtonRepeat from '@/components/PlayerButtonRepeat'
|
|
|
|
import RangeSlider from 'vue-range-slider'
|
|
|
|
import webapi from '@/webapi'
|
|
|
|
import * as types from '@/store/mutation_types'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PageNowPlaying',
|
|
|
|
components: { PlayerButtonPlayPause, PlayerButtonNext, PlayerButtonPrevious, PlayerButtonShuffle, PlayerButtonConsume, PlayerButtonRepeat, RangeSlider },
|
|
|
|
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
item_progress_ms: 0,
|
2018-11-09 23:16:25 -05:00
|
|
|
interval_id: 0,
|
|
|
|
artwork_visible: false
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created () {
|
|
|
|
this.item_progress_ms = this.state.item_progress_ms
|
|
|
|
webapi.player_status().then(({ data }) => {
|
|
|
|
this.$store.commit(types.UPDATE_PLAYER_STATUS, data)
|
|
|
|
if (this.state.state === 'play') {
|
|
|
|
this.interval_id = window.setInterval(this.tick, 1000)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
destroyed () {
|
|
|
|
if (this.interval_id > 0) {
|
|
|
|
window.clearTimeout(this.interval_id)
|
|
|
|
this.interval_id = 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
state () {
|
|
|
|
return this.$store.state.player
|
|
|
|
},
|
|
|
|
now_playing () {
|
|
|
|
return this.$store.getters.now_playing
|
2018-10-27 14:57:42 -04:00
|
|
|
},
|
2018-11-09 23:16:25 -05:00
|
|
|
|
|
|
|
artwork_url: function () {
|
|
|
|
if (this.now_playing.artwork_url && this.now_playing.artwork_url.startsWith('/')) {
|
|
|
|
return this.now_playing.artwork_url + '?maxwidth=600&maxheight=600'
|
2018-10-27 14:57:42 -04:00
|
|
|
}
|
2018-11-09 23:16:25 -05:00
|
|
|
return this.now_playing.artwork_url
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
tick: function () {
|
|
|
|
this.item_progress_ms += 1000
|
|
|
|
},
|
|
|
|
|
|
|
|
seek: function (newPosition) {
|
|
|
|
webapi.player_seek(newPosition).catch(() => {
|
|
|
|
this.item_progress_ms = this.state.item_progress_ms
|
|
|
|
})
|
2018-10-27 14:57:42 -04:00
|
|
|
},
|
|
|
|
|
2018-11-09 23:16:25 -05:00
|
|
|
artwork_loaded: function () {
|
|
|
|
this.artwork_visible = true
|
|
|
|
},
|
|
|
|
|
|
|
|
artwork_error: function () {
|
|
|
|
this.artwork_visible = false
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
'state' () {
|
|
|
|
if (this.interval_id > 0) {
|
|
|
|
window.clearTimeout(this.interval_id)
|
|
|
|
this.interval_id = 0
|
|
|
|
}
|
|
|
|
this.item_progress_ms = this.state.item_progress_ms
|
|
|
|
if (this.state.state === 'play') {
|
|
|
|
this.interval_id = window.setInterval(this.tick, 1000)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|