fix queueing
This commit is contained in:
parent
1ee9cba2d3
commit
b41a8a88b3
2 changed files with 24 additions and 23 deletions
|
@ -1194,12 +1194,14 @@ const app = new Vue({
|
||||||
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));
|
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));
|
||||||
;
|
;
|
||||||
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ?? false) : false;
|
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ?? false) : false;
|
||||||
|
|
||||||
console.log(kind, id, isLibrary)
|
console.log(kind, id, isLibrary)
|
||||||
|
app.mk.stop().then(() => {
|
||||||
if (kind.includes("artist")) {
|
if (kind.includes("artist")) {
|
||||||
app.mk.setStationQueue({artist: 'a-' + id}).then(() => {
|
app.mk.setStationQueue({artist: 'a-' + id}).then(() => {
|
||||||
app.mk.play()
|
app.mk.play()
|
||||||
})
|
})
|
||||||
} else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl.u"))){
|
} else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){
|
||||||
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
||||||
function shuffleArray(array) {
|
function shuffleArray(array) {
|
||||||
for (var i = array.length - 1; i > 0; i--) {
|
for (var i = array.length - 1; i > 0; i--) {
|
||||||
|
@ -1209,13 +1211,7 @@ const app = new Vue({
|
||||||
array[j] = temp;
|
array[j] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.mk.clearQueue().then(function () {
|
app.mk.clearQueue().then(function () { {
|
||||||
if ((app.showingPlaylist && app.showingPlaylist.id == id)) {
|
|
||||||
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
|
||||||
if (app.mk.shuffleMode == 1){ shuffleArray(query)}
|
|
||||||
app.mk.queue.append(query)
|
|
||||||
app.mk.play()
|
|
||||||
} else {
|
|
||||||
app.mk.setQueue({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
app.mk.setQueue({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
||||||
app.mk.play().then(function (){
|
app.mk.play().then(function (){
|
||||||
app.mk.clearQueue().then(function (){
|
app.mk.clearQueue().then(function (){
|
||||||
|
@ -1232,7 +1228,12 @@ const app = new Vue({
|
||||||
var playlistId = ''
|
var playlistId = ''
|
||||||
|
|
||||||
try {
|
try {
|
||||||
app.mk.api.library.playlist(id, params).then(res => {
|
function getPlaylist(id, params, isLibrary){
|
||||||
|
if (isLibrary){
|
||||||
|
return app.mk.api.library.playlist(id, params)
|
||||||
|
} else { return app.mk.api.playlist(id, params)}
|
||||||
|
}
|
||||||
|
getPlaylist(id, params, isLibrary).then(res => {
|
||||||
let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
||||||
if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')}
|
if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')}
|
||||||
app.mk.queue.append(query)
|
app.mk.queue.append(query)
|
||||||
|
@ -1268,6 +1269,7 @@ const app = new Vue({
|
||||||
} else {
|
} else {
|
||||||
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
|
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
|
||||||
}
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
async getTypeFromID(kind, id, isLibrary = false, params = {}, params2 = {}) {
|
async getTypeFromID(kind, id, isLibrary = false, params = {}, params2 = {}) {
|
||||||
let a;
|
let a;
|
||||||
|
|
|
@ -395,7 +395,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
playTrack() {
|
playTrack() {
|
||||||
|
|
||||||
let item = this.item
|
let item = this.item
|
||||||
let parent = this.parent
|
let parent = this.parent
|
||||||
let childIndex = this.index
|
let childIndex = this.index
|
||||||
|
@ -403,9 +402,10 @@
|
||||||
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));;
|
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));;
|
||||||
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ?? false) : false;
|
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ?? false) : false;
|
||||||
console.log(item, parent, childIndex, kind, id, isLibrary, kind == "playlists", id.startsWith("p.") || id.startsWith("pl.u"))
|
console.log(item, parent, childIndex, kind, id, isLibrary, kind == "playlists", id.startsWith("p.") || id.startsWith("pl.u"))
|
||||||
|
app.mk.stop().then(() => {
|
||||||
if (parent != null && childIndex != null) {
|
if (parent != null && childIndex != null) {
|
||||||
app.queueParentandplayChild(parent, childIndex, item);
|
app.queueParentandplayChild(parent, childIndex, item);
|
||||||
} else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl.u"))){
|
} else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){
|
||||||
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
||||||
function shuffleArray(array) {
|
function shuffleArray(array) {
|
||||||
for (var i = array.length - 1; i > 0; i--) {
|
for (var i = array.length - 1; i > 0; i--) {
|
||||||
|
@ -416,12 +416,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.mk.clearQueue().then(function () {
|
app.mk.clearQueue().then(function () {
|
||||||
if ((app.showingPlaylist && app.showingPlaylist.id == id)) {
|
|
||||||
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
|
||||||
if (app.mk.shuffleMode == 1){ shuffleArray(query)}
|
|
||||||
app.mk.queue.append(query)
|
|
||||||
app.mk.play()
|
|
||||||
} else {
|
|
||||||
app.mk.setQueue({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
app.mk.setQueue({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
||||||
app.mk.play().then(function (){
|
app.mk.play().then(function (){
|
||||||
app.mk.clearQueue().then(function (){
|
app.mk.clearQueue().then(function (){
|
||||||
|
@ -436,9 +430,14 @@
|
||||||
"fields[songs]": "artistUrl,albumUrl"
|
"fields[songs]": "artistUrl,albumUrl"
|
||||||
}
|
}
|
||||||
var playlistId = ''
|
var playlistId = ''
|
||||||
|
function getPlaylist(id, params, isLibrary){
|
||||||
|
if (isLibrary){
|
||||||
|
return app.mk.api.library.playlist(id, params)
|
||||||
|
} else { return app.mk.api.playlist(id, params)}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
app.mk.api.library.playlist(id, params).then(res => {
|
|
||||||
|
getPlaylist(id, params, isLibrary).then(res => {
|
||||||
let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
||||||
if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')}
|
if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')}
|
||||||
app.mk.queue.append(query)
|
app.mk.queue.append(query)
|
||||||
|
@ -469,11 +468,11 @@
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
app.playMediaItemById(item.attributes.playParams.id ?? item.id, item.attributes.playParams.kind ?? item.type, item.attributes.playParams.isLibrary ?? false, item.attributes.url)
|
app.playMediaItemById(item.attributes.playParams.id ?? item.id, item.attributes.playParams.kind ?? item.type, item.attributes.playParams.isLibrary ?? false, item.attributes.url)
|
||||||
}
|
}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue