mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
feat: cache next track
This commit is contained in:
parent
fee97f7f3c
commit
91ae6bb107
1 changed files with 14 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue