mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-25 04:19:15 -05:00
[web-src] Make use of extended queue/item/add endpoint
Should speed up starting playback from the web ui (reduces number of web api requests)
This commit is contained in:
parent
d931385886
commit
df455ce069
@ -39,23 +39,17 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
play: function () {
|
play: function () {
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
webapi.search({ 'type': 'tracks', 'expression': 'path starts with "' + this.directory.path + '" order by path asc' }).then(({ data }) => {
|
webapi.player_play_expression('path starts with "' + this.directory.path + '" order by path asc', false)
|
||||||
webapi.player_play_uri(data.tracks.items.map(a => a.uri).join(','), false)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
queue_add: function () {
|
queue_add: function () {
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
webapi.search({ 'type': 'tracks', 'expression': 'path starts with "' + this.directory.path + '" order by path asc' }).then(({ data }) => {
|
webapi.queue_expression_add('path starts with "' + this.directory.path + '" order by path asc')
|
||||||
webapi.queue_add(data.tracks.items.map(a => a.uri).join(','))
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
queue_add_next: function () {
|
queue_add_next: function () {
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
webapi.search({ 'type': 'tracks', 'expression': 'path starts with "' + this.directory.path + '" order by path asc' }).then(({ data }) => {
|
webapi.queue_expression_add_next('path starts with "' + this.directory.path + '" order by path asc')
|
||||||
webapi.queue_add_next(data.tracks.items.map(a => a.uri).join(','))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,23 +39,17 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
play: function () {
|
play: function () {
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
webapi.library_genre_tracks(this.genre.name).then(({ data }) =>
|
webapi.player_play_expression('genre is "' + this.genre.name + '" and media_kind is music', false)
|
||||||
webapi.player_play_uri(data.tracks.items.map(a => a.uri).join(','), false)
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
queue_add: function () {
|
queue_add: function () {
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
webapi.library_genre_tracks(this.genre.name).then(({ data }) =>
|
webapi.queue_expression_add('genre is "' + this.genre.name + '" and media_kind is music')
|
||||||
webapi.queue_add(data.tracks.items.map(a => a.uri).join(','))
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
queue_add_next: function () {
|
queue_add_next: function () {
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
webapi.library_genre_tracks(this.genre.name).then(({ data }) =>
|
webapi.queue_expression_add_next('genre is "' + this.genre.name + '" and media_kind is music')
|
||||||
webapi.queue_add_next(data.tracks.items.map(a => a.uri).join(','))
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
open_genre: function () {
|
open_genre: function () {
|
||||||
|
@ -153,9 +153,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
play: function () {
|
play: function () {
|
||||||
webapi.search({ 'type': 'tracks', 'expression': 'path starts with "' + this.current_directory + '" order by path asc' }).then(({ data }) => {
|
webapi.player_play_expression('path starts with "' + this.current_directory + '" order by path asc', false)
|
||||||
webapi.player_play_uri(data.tracks.items.map(a => a.uri).join(','), false)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
play_track: function (position) {
|
play_track: function (position) {
|
||||||
|
@ -85,9 +85,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
play: function () {
|
play: function () {
|
||||||
webapi.library_genre_tracks(this.name).then(({ data }) =>
|
webapi.player_play_expression('genre is "' + this.name + '" and media_kind is music', true)
|
||||||
webapi.player_play_uri(data.tracks.items.map(a => a.uri).join(','), true)
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
open_album: function (album) {
|
open_album: function (album) {
|
||||||
|
@ -84,11 +84,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
play: function () {
|
play: function () {
|
||||||
webapi.player_play_uri(this.tracks.items.map(a => a.uri).join(','), true)
|
webapi.player_play_expression('genre is "' + this.genre + '" and media_kind is music', true)
|
||||||
},
|
},
|
||||||
|
|
||||||
play_track: function (position) {
|
play_track: function (position) {
|
||||||
webapi.player_play_uri(this.tracks.items.map(a => a.uri).join(','), false, position)
|
webapi.player_play_expression('genre is "' + this.genre + '" and media_kind is music', false, position)
|
||||||
},
|
},
|
||||||
|
|
||||||
open_dialog: function (track) {
|
open_dialog: function (track) {
|
||||||
|
@ -41,11 +41,9 @@ export default {
|
|||||||
return axios.put('/api/queue/items/' + itemId + '?new_position=' + newPosition)
|
return axios.put('/api/queue/items/' + itemId + '?new_position=' + newPosition)
|
||||||
},
|
},
|
||||||
|
|
||||||
queue_add (uri, showNotification = true) {
|
queue_add (uri) {
|
||||||
return axios.post('/api/queue/items/add?uris=' + uri).then((response) => {
|
return axios.post('/api/queue/items/add?uris=' + uri).then((response) => {
|
||||||
if (showNotification) {
|
|
||||||
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
||||||
}
|
|
||||||
return Promise.resolve(response)
|
return Promise.resolve(response)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -61,18 +59,54 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
queue_expression_add (expression) {
|
||||||
|
var options = {}
|
||||||
|
options.expression = expression
|
||||||
|
|
||||||
|
return axios.post('/api/queue/items/add', undefined, { params: options }).then((response) => {
|
||||||
|
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
||||||
|
return Promise.resolve(response)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
queue_expression_add_next (expression) {
|
||||||
|
var options = {}
|
||||||
|
options.expression = expression
|
||||||
|
options.position = 0
|
||||||
|
if (store.getters.now_playing && store.getters.now_playing.id) {
|
||||||
|
options.position = store.getters.now_playing.position + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return axios.post('/api/queue/items/add', undefined, { params: options }).then((response) => {
|
||||||
|
store.dispatch('add_notification', { text: response.data.count + ' tracks appended to queue', type: 'info', timeout: 2000 })
|
||||||
|
return Promise.resolve(response)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
player_status () {
|
player_status () {
|
||||||
return axios.get('/api/player')
|
return axios.get('/api/player')
|
||||||
},
|
},
|
||||||
|
|
||||||
player_play_uri (uris, shuffle, position = undefined) {
|
player_play_uri (uris, shuffle, position = undefined) {
|
||||||
return this.queue_clear().then(() =>
|
var options = {}
|
||||||
this.player_shuffle(shuffle).then(() =>
|
options.uris = uris
|
||||||
this.queue_add(uris, false).then(() =>
|
options.shuffle = shuffle ? 'true' : 'false'
|
||||||
this.player_play({ 'position': position })
|
options.clear = 'true'
|
||||||
)
|
options.playback = 'start'
|
||||||
)
|
options.playback_from_position = position
|
||||||
)
|
|
||||||
|
return axios.post('/api/queue/items/add', undefined, { params: options })
|
||||||
|
},
|
||||||
|
|
||||||
|
player_play_expression (expression, shuffle, position = undefined) {
|
||||||
|
var options = {}
|
||||||
|
options.expression = expression
|
||||||
|
options.shuffle = shuffle ? 'true' : 'false'
|
||||||
|
options.clear = 'true'
|
||||||
|
options.playback = 'start'
|
||||||
|
options.playback_from_position = position
|
||||||
|
|
||||||
|
return axios.post('/api/queue/items/add', undefined, { params: options })
|
||||||
},
|
},
|
||||||
|
|
||||||
player_play (options = {}) {
|
player_play (options = {}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user