properly clean up radio hls instances

This commit is contained in:
vapormusic 2022-09-15 22:59:10 +07:00
parent 9ec60515e8
commit 43ed479de4
2 changed files with 12 additions and 3 deletions

View file

@ -58,6 +58,10 @@ const Events = {
try { try {
app.mk._services.mediaItemPlayback._currentPlayer.destroy(); app.mk._services.mediaItemPlayback._currentPlayer.destroy();
} catch (e) {} } catch (e) {}
try {
this.radiohls.destroy()
this.radiohls = null;
} catch (_){}
try { try {
let searchInt = setInterval(function () { let searchInt = setInterval(function () {
if (document.getElementById("apple-music-player")) { if (document.getElementById("apple-music-player")) {

View file

@ -1021,6 +1021,11 @@ const app = new Vue({
return; return;
} // EVIL EMPTY OBJECTS BE GONE } // EVIL EMPTY OBJECTS BE GONE
try {
this.radiohls.destroy()
this.radiohls = null;
} catch (_){}
try { try {
if ((MusicKit.getInstance().nowPlayingItem["type"] ?? "").includes("ideo")) { if ((MusicKit.getInstance().nowPlayingItem["type"] ?? "").includes("ideo")) {
setTimeout(() => { setTimeout(() => {
@ -5078,14 +5083,14 @@ const app = new Vue({
appData: { serviceName: "Apple Music" }, appData: { serviceName: "Apple Music" },
}; };
if (app.radiohls != null && app.radiohls.destroy != null) { if (app.radiohls != null && app.radiohls.destroy != null) {
app.radiohls.destroy(); app.radiohls.destroy();
setTimeout(() => { app.radiohls = null;
app.radiohls = new CiderHls(); app.radiohls = new CiderHls();
app.radiohls.loadSource(e); app.radiohls.loadSource(e);
app.radiohls.attachMedia(app.mk._services.mediaItemPlayback._currentPlayer._targetElement); app.radiohls.attachMedia(app.mk._services.mediaItemPlayback._currentPlayer._targetElement);
app.mk._services.mediaItemPlayback._currentPlayer._targetElement.play(); app.mk._services.mediaItemPlayback._currentPlayer._targetElement.play();
}, 500);
} else { } else {
app.radiohls = null;
app.radiohls = new CiderHls(); app.radiohls = new CiderHls();
app.radiohls.loadSource(e); app.radiohls.loadSource(e);
app.radiohls.attachMedia(app.mk._services.mediaItemPlayback._currentPlayer._targetElement); app.radiohls.attachMedia(app.mk._services.mediaItemPlayback._currentPlayer._targetElement);