mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
fix(utils/player): preload & autoUnlock (#1557)
* fix(utils/player): preload & autoUnlock * style: clang-format & prettier
This commit is contained in:
parent
f88addc95d
commit
ab85c51831
1 changed files with 13 additions and 11 deletions
|
|
@ -1,15 +1,15 @@
|
||||||
import { getTrackDetail, scrobble, getMP3 } from '@/api/track';
|
|
||||||
import shuffle from 'lodash/shuffle';
|
|
||||||
import { Howler, Howl } from 'howler';
|
|
||||||
import { cacheTrackSource, getTrackSource } from '@/utils/db';
|
|
||||||
import { getAlbum } from '@/api/album';
|
import { getAlbum } from '@/api/album';
|
||||||
import { getPlaylistDetail, intelligencePlaylist } from '@/api/playlist';
|
|
||||||
import { getArtist } from '@/api/artist';
|
import { getArtist } from '@/api/artist';
|
||||||
import { personalFM, fmTrash } from '@/api/others';
|
import { trackScrobble, trackUpdateNowPlaying } from '@/api/lastfm';
|
||||||
|
import { fmTrash, personalFM } from '@/api/others';
|
||||||
|
import { getPlaylistDetail, intelligencePlaylist } from '@/api/playlist';
|
||||||
|
import { getMP3, getTrackDetail, scrobble } from '@/api/track';
|
||||||
import store from '@/store';
|
import store from '@/store';
|
||||||
import { isAccountLoggedIn } from '@/utils/auth';
|
import { isAccountLoggedIn } from '@/utils/auth';
|
||||||
import { trackUpdateNowPlaying, trackScrobble } from '@/api/lastfm';
|
import { cacheTrackSource, getTrackSource } from '@/utils/db';
|
||||||
import { isCreateMpris, isCreateTray } from '@/utils/platform';
|
import { isCreateMpris, isCreateTray } from '@/utils/platform';
|
||||||
|
import { Howl, Howler } from 'howler';
|
||||||
|
import shuffle from 'lodash/shuffle';
|
||||||
|
|
||||||
const PLAY_PAUSE_FADE_DURATION = 200;
|
const PLAY_PAUSE_FADE_DURATION = 200;
|
||||||
|
|
||||||
|
|
@ -69,7 +69,9 @@ export default class {
|
||||||
this._playNextList = []; // 当这个list不为空时,会优先播放这个list的歌
|
this._playNextList = []; // 当这个list不为空时,会优先播放这个list的歌
|
||||||
this._isPersonalFM = false; // 是否是私人FM模式
|
this._isPersonalFM = false; // 是否是私人FM模式
|
||||||
this._personalFMTrack = { id: 0 }; // 私人FM当前歌曲
|
this._personalFMTrack = { id: 0 }; // 私人FM当前歌曲
|
||||||
this._personalFMNextTrack = { id: 0 }; // 私人FM下一首歌曲信息(为了快速加载下一首)
|
this._personalFMNextTrack = {
|
||||||
|
id: 0,
|
||||||
|
}; // 私人FM下一首歌曲信息(为了快速加载下一首)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The blob records for cleanup.
|
* The blob records for cleanup.
|
||||||
|
|
@ -192,8 +194,6 @@ export default class {
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
this._loadSelfFromLocalStorage();
|
this._loadSelfFromLocalStorage();
|
||||||
Howler.autoUnlock = false;
|
|
||||||
Howler.usingWebAudio = true;
|
|
||||||
Howler.volume(this.volume);
|
Howler.volume(this.volume);
|
||||||
|
|
||||||
if (this._enabled) {
|
if (this._enabled) {
|
||||||
|
|
@ -227,7 +227,8 @@ export default class {
|
||||||
}
|
}
|
||||||
_setIntervals() {
|
_setIntervals() {
|
||||||
// 同步播放进度
|
// 同步播放进度
|
||||||
// TODO: 如果 _progress 在别的地方被改变了,这个定时器会覆盖之前改变的值,是bug
|
// TODO: 如果 _progress 在别的地方被改变了,
|
||||||
|
// 这个定时器会覆盖之前改变的值,是bug
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if (this._howler === null) return;
|
if (this._howler === null) return;
|
||||||
this._progress = this._howler.seek();
|
this._progress = this._howler.seek();
|
||||||
|
|
@ -313,6 +314,7 @@ export default class {
|
||||||
this._howler = new Howl({
|
this._howler = new Howl({
|
||||||
src: [source],
|
src: [source],
|
||||||
html5: true,
|
html5: true,
|
||||||
|
preload: true,
|
||||||
format: ['mp3', 'flac'],
|
format: ['mp3', 'flac'],
|
||||||
onend: () => {
|
onend: () => {
|
||||||
this._nextTrackCallback();
|
this._nextTrackCallback();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue