|
|
@ -258,19 +258,15 @@ export default class {
|
|
|
|
let trackID = this._playNextList.shift();
|
|
|
|
let trackID = this._playNextList.shift();
|
|
|
|
return [trackID, this.current];
|
|
|
|
return [trackID, this.current];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 循环模式开启,则重新播放当前模式下的相对的下一首
|
|
|
|
// 循环模式开启,则重新播放当前模式下的相对的下一首
|
|
|
|
if (this.repeatMode === 'on') {
|
|
|
|
if (this.repeatMode === 'on') {
|
|
|
|
if (this._reversed && this.current === 0) {
|
|
|
|
if (this._reversed && this.current === 0) {
|
|
|
|
// 倒序模式,当前歌曲是第一首,则重新播放列表最后一首
|
|
|
|
// 倒序模式,当前歌曲是第一首,则重新播放列表最后一首
|
|
|
|
return [this.list[this.list.length - 1], this.list.length - 1];
|
|
|
|
return [this.list[this.list.length - 1], this.list.length - 1];
|
|
|
|
} else if (this.list.length === this.current + 1) {
|
|
|
|
} else if (this.list.length === this.current + 1) {
|
|
|
|
// 正序模式,当前歌曲是最后一首,则重新播放第一首
|
|
|
|
|
|
|
|
return [this.list[0], 0];
|
|
|
|
return [this.list[0], 0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 返回 [trackID, index]
|
|
|
|
|
|
|
|
return [this.list[next], next];
|
|
|
|
return [this.list[next], next];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_getPrevTrack() {
|
|
|
|
_getPrevTrack() {
|
|
|
@ -488,6 +484,8 @@ export default class {
|
|
|
|
if (autoplay && this._currentTrack.name) {
|
|
|
|
if (autoplay && this._currentTrack.name) {
|
|
|
|
this._scrobble(this.currentTrack, this._howler?.seek());
|
|
|
|
this._scrobble(this.currentTrack, this._howler?.seek());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id.constructor === Object)
|
|
|
|
|
|
|
|
return this._replaceCurrentTrackByTrack(id, (autoplay = true));
|
|
|
|
return getTrackDetail(id).then(data => {
|
|
|
|
return getTrackDetail(id).then(data => {
|
|
|
|
const track = data.songs[0];
|
|
|
|
const track = data.songs[0];
|
|
|
|
this._currentTrack = track;
|
|
|
|
this._currentTrack = track;
|
|
|
@ -500,6 +498,20 @@ export default class {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_replaceCurrentTrackByTrack(track, autoplay = true) {
|
|
|
|
|
|
|
|
if (autoplay && this._currentTrack.name) {
|
|
|
|
|
|
|
|
this._scrobble(this.currentTrack, this._howler?.seek());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this._currentTrack = track;
|
|
|
|
|
|
|
|
if (track.url) {
|
|
|
|
|
|
|
|
let replaced = false;
|
|
|
|
|
|
|
|
if (track.id === this.currentTrackID) {
|
|
|
|
|
|
|
|
this._playAudioSource(track.url, autoplay);
|
|
|
|
|
|
|
|
replaced = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return replaced;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @returns 是否成功加载音频,并使用加载完成的音频替换了howler实例
|
|
|
|
* @returns 是否成功加载音频,并使用加载完成的音频替换了howler实例
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -553,7 +565,7 @@ export default class {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_loadSelfFromLocalStorage() {
|
|
|
|
_loadSelfFromLocalStorage() {
|
|
|
|
const player = JSON.parse(localStorage.getItem('player'));
|
|
|
|
let player = JSON.parse(localStorage.getItem('player'));
|
|
|
|
if (!player) return;
|
|
|
|
if (!player) return;
|
|
|
|
for (const [key, value] of Object.entries(player)) {
|
|
|
|
for (const [key, value] of Object.entries(player)) {
|
|
|
|
this[key] = value;
|
|
|
|
this[key] = value;
|
|
|
@ -766,7 +778,6 @@ export default class {
|
|
|
|
if (excludeSaveKeys.includes(key)) continue;
|
|
|
|
if (excludeSaveKeys.includes(key)) continue;
|
|
|
|
player[key] = value;
|
|
|
|
player[key] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
localStorage.setItem('player', JSON.stringify(player));
|
|
|
|
localStorage.setItem('player', JSON.stringify(player));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -833,7 +844,6 @@ export default class {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this._howler?._sounds[0]._node.setSinkId(store.state.settings.outputDevice);
|
|
|
|
this._howler?._sounds[0]._node.setSinkId(store.state.settings.outputDevice);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
replacePlaylist(
|
|
|
|
replacePlaylist(
|
|
|
|
trackIDs,
|
|
|
|
trackIDs,
|
|
|
|
playlistSourceID,
|
|
|
|
playlistSourceID,
|
|
|
@ -842,6 +852,7 @@ export default class {
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
this._isPersonalFM = false;
|
|
|
|
this._isPersonalFM = false;
|
|
|
|
if (!this._enabled) this._enabled = true;
|
|
|
|
if (!this._enabled) this._enabled = true;
|
|
|
|
|
|
|
|
console.log(trackIDs);
|
|
|
|
this.list = trackIDs;
|
|
|
|
this.list = trackIDs;
|
|
|
|
this.current = 0;
|
|
|
|
this.current = 0;
|
|
|
|
this._playlistSource = {
|
|
|
|
this._playlistSource = {
|
|
|
@ -859,6 +870,7 @@ export default class {
|
|
|
|
playAlbumByID(id, trackID = 'first') {
|
|
|
|
playAlbumByID(id, trackID = 'first') {
|
|
|
|
getAlbum(id).then(data => {
|
|
|
|
getAlbum(id).then(data => {
|
|
|
|
let trackIDs = data.songs.map(t => t.id);
|
|
|
|
let trackIDs = data.songs.map(t => t.id);
|
|
|
|
|
|
|
|
console.log('playAlbumByID');
|
|
|
|
this.replacePlaylist(trackIDs, id, 'album', trackID);
|
|
|
|
this.replacePlaylist(trackIDs, id, 'album', trackID);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -868,12 +880,14 @@ export default class {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
getPlaylistDetail(id, noCache).then(data => {
|
|
|
|
getPlaylistDetail(id, noCache).then(data => {
|
|
|
|
let trackIDs = data.playlist.trackIds.map(t => t.id);
|
|
|
|
let trackIDs = data.playlist.trackIds.map(t => t.id);
|
|
|
|
|
|
|
|
console.log('getPlaylistDetail');
|
|
|
|
this.replacePlaylist(trackIDs, id, 'playlist', trackID);
|
|
|
|
this.replacePlaylist(trackIDs, id, 'playlist', trackID);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
playArtistByID(id, trackID = 'first') {
|
|
|
|
playArtistByID(id, trackID = 'first') {
|
|
|
|
getArtist(id).then(data => {
|
|
|
|
getArtist(id).then(data => {
|
|
|
|
let trackIDs = data.hotSongs.map(t => t.id);
|
|
|
|
let trackIDs = data.hotSongs.map(t => t.id);
|
|
|
|
|
|
|
|
console.log('playArtistByID');
|
|
|
|
this.replacePlaylist(trackIDs, id, 'artist', trackID);
|
|
|
|
this.replacePlaylist(trackIDs, id, 'artist', trackID);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -891,6 +905,7 @@ export default class {
|
|
|
|
const songId = data.playlist.trackIds[randomId].id;
|
|
|
|
const songId = data.playlist.trackIds[randomId].id;
|
|
|
|
intelligencePlaylist({ id: songId, pid: id }).then(result => {
|
|
|
|
intelligencePlaylist({ id: songId, pid: id }).then(result => {
|
|
|
|
let trackIDs = result.data.map(t => t.id);
|
|
|
|
let trackIDs = result.data.map(t => t.id);
|
|
|
|
|
|
|
|
console.log('playIntelligenceListById');
|
|
|
|
this.replacePlaylist(trackIDs, id, 'playlist', trackID);
|
|
|
|
this.replacePlaylist(trackIDs, id, 'playlist', trackID);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|