This commit is contained in:
vapormusic 2021-12-17 20:52:17 +07:00
commit 7289ab525d
3 changed files with 41 additions and 10 deletions

View file

@ -576,7 +576,7 @@ const app = new Vue({
}
},
async getNowPlayingItemDetailed(target) {
let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem.id, {"include[songs]": "albums,artists"});
let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], {"include[songs]": "albums,artists"});
app.searchAndNavigate(u, target)
},
async searchAndNavigate(item, target) {
@ -1656,17 +1656,18 @@ const app = new Vue({
return newurl
},
getNowPlayingArtworkBG(size = 600) {
if(typeof this.mk.nowPlayingItem === "undefined") return;
let bginterval = setInterval(() => {
if (!this.mkReady()) {
return ""
}
try {
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem.id && this.mk.nowPlayingItem.id != this.currentTrackID && document.querySelector('.bg-artwork')) {
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem["id"] != this.currentTrackID && document.querySelector('.bg-artwork')) {
if (document.querySelector('.bg-artwork')) {
clearInterval(bginterval);
}
this.currentTrackID = this.mk.nowPlayingItem.id;
this.currentTrackID = this.mk.nowPlayingItem["id"];
document.querySelector('.bg-artwork').src = "";
if (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"]) {
document.querySelector('.bg-artwork').src = this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"].replace('{w}', size).replace('{h}', size);
@ -1674,21 +1675,22 @@ const app = new Vue({
} else {
this.setLibraryArtBG()
}
} else if (this.mk.nowPlayingItem.id == this.currentTrackID){
} else if (this.mk.nowPlayingItem["id"] == this.currentTrackID){
try { clearInterval(bginterval); } catch (err) { console.log(err) }
}
} catch (e) {
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem.id && document.querySelector('.bg-artwork')){
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem["id"] && document.querySelector('.bg-artwork')){
this.setLibraryArtBG()}
}
}, 200)
},
getNowPlayingArtwork(size = 600) {
if(typeof this.mk.nowPlayingItem === "undefined") return;
let interval = setInterval(() => {
try {
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem.id && this.mk.nowPlayingItem.id != this.currentTrackIDBG && document.querySelector('.app-playback-controls .artwork')) {
this.currentTrackIDBG = this.mk.nowPlayingItem.id;
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem["id"] != this.currentTrackIDBG && document.querySelector('.app-playback-controls .artwork')) {
this.currentTrackIDBG = this.mk.nowPlayingItem["id"];
if (document.querySelector('.app-playback-controls .artwork') != null) {
clearInterval(interval);
}
@ -1699,11 +1701,11 @@ const app = new Vue({
} else {
this.setLibraryArt()
}
} else if (this.mk.nowPlayingItem.id == this.currentTrackID){
} else if (this.mk.nowPlayingItem["id"] == this.currentTrackID){
try { clearInterval(interval); } catch (err) { console.log(err) }
}
} catch (e) {
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem.id && document.querySelector('.app-playback-controls .artwork')){
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem["id"] && document.querySelector('.app-playback-controls .artwork')){
this.setLibraryArt()}
}
@ -1712,6 +1714,8 @@ const app = new Vue({
},
async setLibraryArt() {
if(typeof this.mk.nowPlayingItem === "undefined") return;
const data = await this.mk.api.library.song(this.mk.nowPlayingItem["id"])
try {
const data = await this.mk.api.library.song(this.mk.nowPlayingItem.id)
@ -1724,6 +1728,8 @@ const app = new Vue({
}
},
async setLibraryArtBG() {
if(typeof this.mk.nowPlayingItem === "undefined") return;
const data = await this.mk.api.library.song(this.mk.nowPlayingItem["id"])
try {
const data = await this.mk.api.library.song(this.mk.nowPlayingItem.id)