revert some queue extension tricks as MKjs does not like it
This commit is contained in:
parent
4a9ddd0f3a
commit
c07d650a69
4 changed files with 163 additions and 190 deletions
|
@ -1202,72 +1202,74 @@ const app = new Vue({
|
||||||
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."))){
|
}
|
||||||
/* Randomize array in-place using Durstenfeld shuffle algorithm */
|
// else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){
|
||||||
function shuffleArray(array) {
|
// /* Randomize array in-place using Durstenfeld shuffle algorithm */
|
||||||
for (var i = array.length - 1; i > 0; i--) {
|
// function shuffleArray(array) {
|
||||||
var j = Math.floor(Math.random() * (i + 1));
|
// for (var i = array.length - 1; i > 0; i--) {
|
||||||
var temp = array[i];
|
// var j = Math.floor(Math.random() * (i + 1));
|
||||||
array[i] = array[j];
|
// var temp = array[i];
|
||||||
array[j] = temp;
|
// array[i] = array[j];
|
||||||
}
|
// array[j] = temp;
|
||||||
}
|
// }
|
||||||
app.mk.clearQueue().then(function () { {
|
// }
|
||||||
app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () {
|
// app.mk.clearQueue().then(function () { {
|
||||||
app.mk.play().then(function (){
|
// app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () {
|
||||||
app.mk.clearQueue().then(function (){
|
// app.mk.play().then(function (){
|
||||||
var playlistId = id
|
// app.mk.clearQueue().then(function (){
|
||||||
const params = {
|
// var playlistId = id
|
||||||
include: "tracks",
|
// const params = {
|
||||||
platform: "web",
|
// include: "tracks",
|
||||||
"include[library-playlists]": "catalog,tracks",
|
// platform: "web",
|
||||||
"fields[playlists]": "curatorName,playlistType,name,artwork,url",
|
// "include[library-playlists]": "catalog,tracks",
|
||||||
"include[library-songs]": "catalog,artists,albums",
|
// "fields[playlists]": "curatorName,playlistType,name,artwork,url",
|
||||||
"fields[catalog]": "artistUrl,albumUrl",
|
// "include[library-songs]": "catalog,artists,albums",
|
||||||
"fields[songs]": "artistUrl,albumUrl"
|
// "fields[catalog]": "artistUrl,albumUrl",
|
||||||
}
|
// "fields[songs]": "artistUrl,albumUrl"
|
||||||
var playlistId = ''
|
// }
|
||||||
|
// var playlistId = ''
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
function getPlaylist(id, params, isLibrary){
|
// function getPlaylist(id, params, isLibrary){
|
||||||
if (isLibrary){
|
// if (isLibrary){
|
||||||
return app.mk.api.library.playlist(id, params)
|
// return app.mk.api.library.playlist(id, params)
|
||||||
} else { return app.mk.api.playlist(id, params)}
|
// } else { return app.mk.api.playlist(id, params)}
|
||||||
}
|
// }
|
||||||
getPlaylist(id, params, isLibrary).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)
|
||||||
if (!res.relationships.tracks.next) {
|
// if (!res.relationships.tracks.next) {
|
||||||
return
|
// return
|
||||||
} else {
|
// } else {
|
||||||
getPlaylistTracks(res.relationships.tracks.next)
|
// getPlaylistTracks(res.relationships.tracks.next)
|
||||||
}
|
// }
|
||||||
|
|
||||||
function getPlaylistTracks(next) {
|
// function getPlaylistTracks(next) {
|
||||||
app.apiCall(app.musicBaseUrl + next, res => {
|
// app.apiCall(app.musicBaseUrl + next, res => {
|
||||||
if (res.id != playlistId) {
|
// if (res.id != playlistId) {
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
let query = res.data.map(item => new MusicKit.MediaItem(item))
|
// let query = res.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)
|
||||||
|
|
||||||
if (res.next) {
|
// if (res.next) {
|
||||||
getPlaylistTracks(res.next)
|
// getPlaylistTracks(res.next)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
} catch (e) {}
|
// } catch (e) {}
|
||||||
|
|
||||||
|
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
} else {
|
// }
|
||||||
|
else {
|
||||||
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
|
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2371,10 +2373,7 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
try {
|
app.mk.stop().then(() => {
|
||||||
app.mk.stop()
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))){
|
if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))){
|
||||||
app.mk.playNext({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
app.mk.playNext({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
||||||
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1)
|
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1)
|
||||||
|
@ -2412,7 +2411,7 @@ const app = new Vue({
|
||||||
app.mk.play()
|
app.mk.play()
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
}
|
})}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script type="text/x-template" id="fullscreen-view">
|
<script type="text/x-template" id="fullscreen-view">
|
||||||
<div class="fullscreen-view">
|
<div class="fullscreen-view" tabindex="0">
|
||||||
<div class="background">
|
<div class="background">
|
||||||
<div class="bgArtworkMaterial">
|
<div class="bgArtworkMaterial">
|
||||||
<div class="bg-artwork-container">
|
<div class="bg-artwork-container">
|
||||||
|
@ -140,10 +140,19 @@
|
||||||
tabMode: "lyrics",
|
tabMode: "lyrics",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeMount() {
|
||||||
|
window.addEventListener('keyup', this.onEscapeKeyUp);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
window.removeEventListener('keyup', this.onEscapeKeyUp)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
sayHello: function () {
|
onEscapeKeyUp(event) {
|
||||||
alert('Hello world!');
|
if (event.which === 27) {
|
||||||
}
|
app.fullscreen(false);
|
||||||
|
console.log('js')
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
|
@ -415,73 +415,75 @@
|
||||||
app.mk.stop().then(() => {
|
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."))){
|
}
|
||||||
function shuffleArray(array) {
|
// else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){
|
||||||
for (var i = array.length - 1; i > 0; i--) {
|
// function shuffleArray(array) {
|
||||||
var j = Math.floor(Math.random() * (i + 1));
|
// for (var i = array.length - 1; i > 0; i--) {
|
||||||
var temp = array[i];
|
// var j = Math.floor(Math.random() * (i + 1));
|
||||||
array[i] = array[j];
|
// var temp = array[i];
|
||||||
array[j] = temp;
|
// array[i] = array[j];
|
||||||
}
|
// array[j] = temp;
|
||||||
}
|
// }
|
||||||
app.mk.clearQueue().then(function () {
|
// }
|
||||||
app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () {
|
// app.mk.clearQueue().then(function () {
|
||||||
app.mk.play().then(function (){
|
// app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () {
|
||||||
app.mk.clearQueue().then(function (){
|
// app.mk.play().then(function (){
|
||||||
var playlistId = id
|
// app.mk.clearQueue().then(function (){
|
||||||
const params = {
|
// var playlistId = id
|
||||||
// include: "tracks",
|
// const params = {
|
||||||
// platform: "web",
|
// // include: "tracks",
|
||||||
// "include[library-playlists]": "catalog,tracks",
|
// // platform: "web",
|
||||||
// "fields[playlists]": "curatorName,playlistType,name,artwork,url",
|
// // "include[library-playlists]": "catalog,tracks",
|
||||||
// "include[library-songs]": "catalog,artists,albums",
|
// // "fields[playlists]": "curatorName,playlistType,name,artwork,url",
|
||||||
// "fields[catalog]": "artistUrl,albumUrl",
|
// // "include[library-songs]": "catalog,artists,albums",
|
||||||
// "fields[songs]": "artistUrl,albumUrl, playParams"
|
// // "fields[catalog]": "artistUrl,albumUrl",
|
||||||
}
|
// // "fields[songs]": "artistUrl,albumUrl, playParams"
|
||||||
// var playlistId = ''
|
// }
|
||||||
function getPlaylist(id, params, isLibrary){
|
// // var playlistId = ''
|
||||||
if (isLibrary){
|
// function getPlaylist(id, params, isLibrary){
|
||||||
return app.mk.api.library.playlist(id, params)
|
// if (isLibrary){
|
||||||
} else { return app.mk.api.playlist(id, params)}
|
// return app.mk.api.library.playlist(id, params)
|
||||||
}
|
// } else { return app.mk.api.playlist(id, params)}
|
||||||
try {
|
// }
|
||||||
|
// try {
|
||||||
|
|
||||||
getPlaylist(id, params, isLibrary).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); }
|
// if (app.mk.shuffleMode == 1){shuffleArray(query); }
|
||||||
console.log(query)
|
// console.log(query)
|
||||||
app.mk.queue.append(query)
|
// app.mk.queue.append(query)
|
||||||
if (!res.relationships.tracks.next) {
|
// if (!res.relationships.tracks.next) {
|
||||||
return
|
// return
|
||||||
} else {
|
// } else {
|
||||||
getPlaylistTracks(res.relationships.tracks.next)
|
// getPlaylistTracks(res.relationships.tracks.next)
|
||||||
}
|
// }
|
||||||
|
|
||||||
function getPlaylistTracks(next) {
|
// function getPlaylistTracks(next) {
|
||||||
app.apiCall(app.musicBaseUrl + next, res => {
|
// app.apiCall(app.musicBaseUrl + next, res => {
|
||||||
// if (res.id != playlistId || next.includes(playlistId)) {
|
// // if (res.id != playlistId || next.includes(playlistId)) {
|
||||||
// return
|
// // return
|
||||||
// }
|
// // }
|
||||||
console.log('nextres', res)
|
// console.log('nextres', res)
|
||||||
let query = res.data.map(item => new MusicKit.MediaItem(item))
|
// let query = res.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)
|
||||||
|
|
||||||
if (res.next) {
|
// if (res.next) {
|
||||||
getPlaylistTracks(res.next)
|
// getPlaylistTracks(res.next)
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
} catch (e) {}
|
// } catch (e) {}
|
||||||
|
|
||||||
|
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
|
|
||||||
})
|
// })
|
||||||
} 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)
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
Play
|
Play
|
||||||
</button>
|
</button>
|
||||||
<button class="wr-btn" style="min-width: 120px;"
|
<button class="wr-btn" style="min-width: 120px;"
|
||||||
@click="shufflePlay()">
|
@click="app.mk.shuffleMode = 1; app.mk.stop().then(function() {app.playMediaItemById(data.attributes.playParams.id ?? data.id, data.attributes.playParams.kind ?? data.type, data.attributes.playParams.isLibrary ?? false, data.attributes.url)})">
|
||||||
Shuffle
|
Shuffle
|
||||||
</button>
|
</button>
|
||||||
<button class="wr-btn" style="min-width: 120px;" v-if="inLibrary!=null"
|
<button class="wr-btn" style="min-width: 120px;" v-if="inLibrary!=null"
|
||||||
|
@ -323,72 +323,35 @@
|
||||||
array[j] = temp;
|
array[j] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var id = this.data.attributes.playParams.id ?? this.data.id
|
//var id = this.data.attributes.playParams.id ?? this.data.id;
|
||||||
let kind = this.data.attributes.playParams.kind ?? this.data.type ?? '';
|
//console.log("1")
|
||||||
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
var kind = this.data.attributes.playParams.kind ?? this.data.type ?? '';
|
||||||
let isLibrary = this.data.attributes.playParams ? (this.data.attributes.playParams.isLibrary ?? false) : false;
|
//console.log("1")
|
||||||
app.mk.stop().then(function() {
|
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||||
app.mk.clearQueue().then(function () {
|
// console.log("1")
|
||||||
app.mk.setQueue({ [truekind] : [id] }).then(function () {
|
// var isLibrary = this.data.attributes.playParams ? (this.data.attributes.playParams.isLibrary ?? false) : false;
|
||||||
|
console.log("1")
|
||||||
|
app.mk.stop().then(function () {
|
||||||
|
console.log("2")
|
||||||
|
app.mk.setQueue({ [truekind]: [id] }).then(function () {
|
||||||
app.mk.play().then(function () {
|
app.mk.play().then(function () {
|
||||||
app.mk.clearQueue().then(function () {
|
if (!kind.includes("album"))
|
||||||
const params = {
|
app.mk.clearQueue().then(function () {
|
||||||
// include: "tracks",
|
try {
|
||||||
// platform: "web",
|
let query = (this.data ?? app.showingPlaylist).relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
||||||
// "include[library-playlists]": "catalog,tracks",
|
if (app.mk.shuffleMode == 1) { shuffleArray(query) }
|
||||||
// "fields[playlists]": "curatorName,playlistType,name,artwork,url",
|
|
||||||
// "include[library-songs]": "catalog,artists,albums",
|
|
||||||
// "fields[catalog]": "artistUrl,albumUrl",
|
|
||||||
// "fields[songs]": "artistUrl,albumUrl, playParams"
|
|
||||||
}
|
|
||||||
function getList(kind, id, params, isLibrary) {
|
|
||||||
if (kind.includes("album")){
|
|
||||||
if (isLibrary) {
|
|
||||||
return app.mk.api.library.album(id, params)
|
|
||||||
} else { return app.mk.api.album(id, params) }
|
|
||||||
} else {
|
|
||||||
if (isLibrary) {
|
|
||||||
return app.mk.api.library.playlist(id, params)
|
|
||||||
} else { return app.mk.api.playlist(id, params) }}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
|
|
||||||
getList(kind, id, params, isLibrary).then(res => {
|
|
||||||
console.log(res)
|
|
||||||
let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
|
||||||
if (app.mk.shuffleMode == 1) { shuffleArray(query); console.log('shf') }
|
|
||||||
app.mk.queue.append(query)
|
app.mk.queue.append(query)
|
||||||
if (!res.relationships.tracks.next) {
|
} catch (e) { console.log(e) }
|
||||||
return
|
|
||||||
} else {
|
|
||||||
getPlaylistTracks(res.relationships.tracks.next)
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPlaylistTracks(next) {
|
|
||||||
app.apiCall(app.musicBaseUrl + next, res => {
|
|
||||||
// if (res.id != playlistId) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
let query = res.data.map(item => new MusicKit.MediaItem(item))
|
|
||||||
if (app.mk.shuffleMode == 1) { shuffleArray(query); console.log('shf') }
|
|
||||||
app.mk.queue.append(query)
|
|
||||||
|
|
||||||
if (res.next) {
|
|
||||||
getPlaylistTracks(res.next)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (e) {console.log(e) }
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
})}
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue