From c97f94fec2f89364351638ddfd87489c3bf84b43 Mon Sep 17 00:00:00 2001 From: chme Date: Tue, 6 Nov 2018 21:44:01 +0100 Subject: [PATCH] [web-src] Starting playback now explicitely turns shuffle mode on/off Additionally some small refactoring to make starting playback for an uri easier. --- web-src/src/components/ListItemAlbum.vue | 6 +---- web-src/src/components/ListItemArtist.vue | 6 +---- web-src/src/components/ListItemGenre.vue | 18 +++++++-------- web-src/src/components/ListItemPlaylist.vue | 6 +---- web-src/src/components/ListItemQueueItem.vue | 2 +- web-src/src/components/ListItemTrack.vue | 12 ++-------- .../src/components/SpotifyListItemAlbum.vue | 6 +---- .../src/components/SpotifyListItemArtist.vue | 6 +---- .../components/SpotifyListItemPlaylist.vue | 6 +---- .../src/components/SpotifyListItemTrack.vue | 6 +---- web-src/src/pages/PageAlbum.vue | 22 +++++++++---------- web-src/src/pages/PageArtist.vue | 11 ++-------- web-src/src/pages/PageAudiobook.vue | 6 +---- web-src/src/pages/PageGenre.vue | 11 ++-------- web-src/src/pages/PagePlaylist.vue | 11 ++-------- web-src/src/pages/PagePodcast.vue | 6 +---- web-src/src/pages/PageTracks.vue | 11 ++-------- web-src/src/pages/SpotifyPageAlbum.vue | 11 ++-------- web-src/src/pages/SpotifyPagePlaylist.vue | 11 ++-------- web-src/src/webapi/index.js | 14 ++++++++++-- 20 files changed, 55 insertions(+), 133 deletions(-) diff --git a/web-src/src/components/ListItemAlbum.vue b/web-src/src/components/ListItemAlbum.vue index 70bb8461..91ed52d8 100644 --- a/web-src/src/components/ListItemAlbum.vue +++ b/web-src/src/components/ListItemAlbum.vue @@ -67,11 +67,7 @@ export default { methods: { play: function () { this.show_details_modal = false - webapi.queue_clear().then(() => - webapi.queue_add(this.album.uri).then(() => - webapi.player_play() - ) - ) + webapi.player_play_uri(this.album.uri, false) }, queue_add: function () { diff --git a/web-src/src/components/ListItemArtist.vue b/web-src/src/components/ListItemArtist.vue index 58b733c7..795de846 100644 --- a/web-src/src/components/ListItemArtist.vue +++ b/web-src/src/components/ListItemArtist.vue @@ -62,11 +62,7 @@ export default { methods: { play: function () { this.show_details_modal = false - webapi.queue_clear().then(() => - webapi.queue_add(this.artist.uri).then(() => - webapi.player_play() - ) - ) + webapi.player_play_uri(this.artist.uri, false) }, queue_add: function () { diff --git a/web-src/src/components/ListItemGenre.vue b/web-src/src/components/ListItemGenre.vue index 09190ff6..e0675b92 100644 --- a/web-src/src/components/ListItemGenre.vue +++ b/web-src/src/components/ListItemGenre.vue @@ -64,29 +64,27 @@ export default { methods: { play: function () { this.show_details_modal = false - webapi.queue_clear().then(() => - webapi.library_genre(this.genre.name).then(({ data }) => - webapi.queue_add(data.albums.items.map(a => a.uri).join(',')).then(() => - webapi.player_play() - ) - ) + webapi.library_genre(this.genre.name).then(({ data }) => + webapi.player_play_uri(data.albums.items.map(a => a.uri).join(','), false) ) }, queue_add: function () { this.show_details_modal = false webapi.library_genre(this.genre.name).then(({ data }) => - webapi.queue_add(data.albums.items.map(a => a.uri).join(',')) + webapi.queue_add(data.albums.items.map(a => a.uri).join(',')).then(() => + this.$store.dispatch('add_notification', { text: 'Genre albums appended to queue', type: 'info', timeout: 1500 }) + ) ) - this.$store.dispatch('add_notification', { text: 'Genre albums appended to queue', type: 'info', timeout: 1500 }) }, queue_add_next: function () { this.show_details_modal = false webapi.library_genre(this.genre.name).then(({ data }) => - webapi.queue_add_next(data.albums.items.map(a => a.uri).join(',')) + webapi.queue_add_next(data.albums.items.map(a => a.uri).join(',')).then(() => + this.$store.dispatch('add_notification', { text: 'Genre albums playing next', type: 'info', timeout: 1500 }) + ) ) - this.$store.dispatch('add_notification', { text: 'Genre albums playing next', type: 'info', timeout: 1500 }) }, open_genre: function () { diff --git a/web-src/src/components/ListItemPlaylist.vue b/web-src/src/components/ListItemPlaylist.vue index efdeabd1..1adf756b 100644 --- a/web-src/src/components/ListItemPlaylist.vue +++ b/web-src/src/components/ListItemPlaylist.vue @@ -58,11 +58,7 @@ export default { methods: { play: function () { this.show_details_modal = false - webapi.queue_clear().then(() => - webapi.queue_add(this.playlist.uri).then(() => - webapi.player_play() - ) - ) + webapi.player_play_uri(this.playlist.uri, false) }, queue_add: function () { diff --git a/web-src/src/components/ListItemQueueItem.vue b/web-src/src/components/ListItemQueueItem.vue index 78663d15..b7b4577a 100644 --- a/web-src/src/components/ListItemQueueItem.vue +++ b/web-src/src/components/ListItemQueueItem.vue @@ -107,7 +107,7 @@ export default { play: function () { this.show_details_modal = false - webapi.player_playid(this.item.id) + webapi.player_play({ 'item_id': this.item.id }) } } } diff --git a/web-src/src/components/ListItemTrack.vue b/web-src/src/components/ListItemTrack.vue index 126315f9..ef1ae984 100644 --- a/web-src/src/components/ListItemTrack.vue +++ b/web-src/src/components/ListItemTrack.vue @@ -99,20 +99,12 @@ export default { methods: { play: function () { this.show_details_modal = false - webapi.queue_clear().then(() => - webapi.queue_add(this.context_uri).then(() => - webapi.player_playpos(this.position) - ) - ) + webapi.player_play_uri(this.context_uri, false, this.position) }, play_track: function () { this.show_details_modal = false - webapi.queue_clear().then(() => - webapi.queue_add(this.track.uri).then(() => - webapi.player_play() - ) - ) + webapi.player_play_uri(this.track.uri, false) }, queue_add: function () { diff --git a/web-src/src/components/SpotifyListItemAlbum.vue b/web-src/src/components/SpotifyListItemAlbum.vue index a138921d..09fb82ed 100644 --- a/web-src/src/components/SpotifyListItemAlbum.vue +++ b/web-src/src/components/SpotifyListItemAlbum.vue @@ -68,12 +68,8 @@ export default { methods: { play: function () { - webapi.queue_clear().then(() => - webapi.queue_add(this.album.uri).then(() => - webapi.player_play() - ) - ) this.show_details_modal = false + webapi.player_play_uri(this.album.uri, false) }, queue_add: function () { diff --git a/web-src/src/components/SpotifyListItemArtist.vue b/web-src/src/components/SpotifyListItemArtist.vue index c4ddfe0f..404e67f7 100644 --- a/web-src/src/components/SpotifyListItemArtist.vue +++ b/web-src/src/components/SpotifyListItemArtist.vue @@ -63,12 +63,8 @@ export default { methods: { play: function () { - webapi.queue_clear().then(() => - webapi.queue_add(this.artist.uri).then(() => - webapi.player_play() - ) - ) this.show_details_modal = false + webapi.player_play_uri(this.artist.uri, false) }, queue_add: function () { diff --git a/web-src/src/components/SpotifyListItemPlaylist.vue b/web-src/src/components/SpotifyListItemPlaylist.vue index bc0ff9a4..c4688d41 100644 --- a/web-src/src/components/SpotifyListItemPlaylist.vue +++ b/web-src/src/components/SpotifyListItemPlaylist.vue @@ -68,12 +68,8 @@ export default { methods: { play: function () { - webapi.queue_clear().then(() => - webapi.queue_add(this.playlist.uri).then(() => - webapi.player_play() - ) - ) this.show_details_modal = false + webapi.player_play_uri(this.playlist.uri, false) }, queue_add: function () { diff --git a/web-src/src/components/SpotifyListItemTrack.vue b/web-src/src/components/SpotifyListItemTrack.vue index d65038df..a4407b72 100644 --- a/web-src/src/components/SpotifyListItemTrack.vue +++ b/web-src/src/components/SpotifyListItemTrack.vue @@ -83,12 +83,8 @@ export default { methods: { play: function () { - webapi.queue_clear().then(() => - webapi.queue_add(this.context_uri).then(() => - webapi.player_playpos(this.position) - ) - ) this.show_details_modal = false + webapi.player_play_uri(this.context_uri, false, this.position) }, queue_add: function () { diff --git a/web-src/src/pages/PageAlbum.vue b/web-src/src/pages/PageAlbum.vue index dae4f2d6..4992e870 100644 --- a/web-src/src/pages/PageAlbum.vue +++ b/web-src/src/pages/PageAlbum.vue @@ -5,12 +5,16 @@ {{ album.artist }}