[web-src] Make artwork responsive, change error handling if

an item has no artwork plus some small styling changes
This commit is contained in:
chme 2018-11-10 05:16:25 +01:00
parent 357a0e611a
commit 7ef4e9dd74
4 changed files with 65 additions and 21 deletions

View File

@ -30,12 +30,40 @@ a.navbar-item {
cursor: move; cursor: move;
} }
.fd-has-margin-top {
margin-top: 24px;
}
.fd-has-margin-bottom {
margin-bottom: 24px;
}
.fd-has-padding-left-right {
padding-left: 24px;
padding-right: 24px;
}
.fd-is-text-clipped { .fd-is-text-clipped {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.fd-is-fullheight {
height: calc(100vh - 3.25rem - 3.25rem);
}
.fd-is-fullheight-body {
flex-shrink: 1;
overflow: hidden;
height: 100%
}
.fd-image-fullheight {
height: 100%;
width: auto;
}
.fd-tabs-section { .fd-tabs-section {
padding-bottom: 0; padding-bottom: 0;
} }
@ -44,6 +72,10 @@ a.navbar-item {
top: 52px !important; top: 52px !important;
} }
.fd-has-shadow {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.sortable-chosen .media-right { .sortable-chosen .media-right {
visibility: hidden; visibility: hidden;
} }

View File

@ -1,18 +1,23 @@
<template> <template>
<section class="hero"> <section class="hero fd-is-fullheight">
<div class="hero-body"> <div class="hero-head fd-has-padding-left-right">
<div class="container has-text-centered"> <div class="container has-text-centered fd-has-margin-top">
<p class="heading">NOW PLAYING</p> <h1 class="title is-4">
<h1 class="title is-3">
{{ now_playing.title }} {{ now_playing.title }}
</h1> </h1>
<h2 class="title is-5"> <h2 class="title is-6">
{{ now_playing.artist }} {{ now_playing.artist }}
</h2> </h2>
<h3 class="subtitle is-5"> <h3 class="subtitle is-6">
{{ now_playing.album }} {{ now_playing.album }}
<img class="column is-one-third is-offset-one-third" img :src="artwork_uri" is-square @error="alt_artwork_uri">
</h3> </h3>
</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">
<p class="control has-text-centered fd-progress-now-playing"> <p class="control has-text-centered fd-progress-now-playing">
<range-slider <range-slider
class="seek-slider fd-has-action" class="seek-slider fd-has-action"
@ -27,14 +32,14 @@
<p class="content"> <p class="content">
<span>{{ item_progress_ms | duration }} / {{ now_playing.length_ms | duration }}</span> <span>{{ item_progress_ms | duration }} / {{ now_playing.length_ms | duration }}</span>
</p> </p>
<p class="control has-text-centered"> <div class="buttons has-addons is-centered">
<player-button-previous class="button is-medium"></player-button-previous> <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-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-next class="button is-medium"></player-button-next>
<player-button-repeat class="button is-medium is-light"></player-button-repeat> <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-shuffle class="button is-medium is-light"></player-button-shuffle>
<player-button-consume class="button is-medium is-light"></player-button-consume> <player-button-consume class="button is-medium is-light"></player-button-consume>
</p> </div>
</div> </div>
</div> </div>
</section> </section>
@ -58,7 +63,8 @@ export default {
data () { data () {
return { return {
item_progress_ms: 0, item_progress_ms: 0,
interval_id: 0 interval_id: 0,
artwork_visible: false
} }
}, },
@ -86,12 +92,12 @@ export default {
now_playing () { now_playing () {
return this.$store.getters.now_playing return this.$store.getters.now_playing
}, },
artwork_uri () {
if (this.state.artwork_url === undefined) { artwork_url: function () {
return '' if (this.now_playing.artwork_url && this.now_playing.artwork_url.startsWith('/')) {
return this.now_playing.artwork_url + '?maxwidth=600&maxheight=600'
} }
// for dev add 'http://localhost:3689' return this.now_playing.artwork_url
return this.state.artwork_url + '?item_id=' + this.state.item_id
} }
}, },
@ -106,8 +112,12 @@ export default {
}) })
}, },
alt_artwork_uri: function (event) { artwork_loaded: function () {
event.target.src = '/artwork-default.png' this.artwork_visible = true
},
artwork_error: function () {
this.artwork_visible = false
} }
}, },

View File

@ -29,8 +29,7 @@ export default new Vuex.Store({
'volume': 0, 'volume': 0,
'item_id': 0, 'item_id': 0,
'item_length_ms': 0, 'item_length_ms': 0,
'item_progress_ms': 0, 'item_progress_ms': 0
'artwork_url': ''
}, },
queue: { queue: {
'version': 0, 'version': 0,

View File

@ -7,7 +7,7 @@ module.exports = {
// Output path for the generated index.html // Output path for the generated index.html
indexPath: 'index.html', indexPath: 'index.html',
assetsDir: 'player', assetsDir: 'player',
// Do not add hashes to the generated js/css filenames, would otherwise // Do not add hashes to the generated js/css filenames, would otherwise
@ -25,6 +25,9 @@ module.exports = {
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:3689', target: 'http://localhost:3689',
},
'/artwork': {
target: 'http://localhost:3689',
} }
} }
} }