feat: cache next track

master
qier222 4 years ago
parent fee97f7f3c
commit 91ae6bb107
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D

@ -255,6 +255,7 @@ export default class {
return this._getAudioSource(track).then((source) => {
if (source) {
this._playAudioSource(source, autoplay);
this._cacheNextTrack();
return source;
} else {
store.dispatch("showToast", `无法播放 ${track.name}`);
@ -265,6 +266,19 @@ export default class {
});
});
}
_cacheNextTrack() {
const nextTrack = this._getNextTrack();
getTrackDetail(nextTrack[0]).then((data) => {
let track = data.songs[0];
this._getAudioSourceFromCache(String(track.id))
.then((source) => {
return source ?? this._getAudioSourceFromNetease(track);
})
.then((source) => {
return source ?? this._getAudioSourceFromUnblockMusic(track);
});
});
}
_loadSelfFromLocalStorage() {
const player = JSON.parse(localStorage.getItem("player"));
if (!player) return;

Loading…
Cancel
Save