Skip to content

Commit

Permalink
fix(utils/player): preload & autoUnlock (#1557)
Browse files Browse the repository at this point in the history
* fix(utils/player): preload & autoUnlock

* style: clang-format & prettier
  • Loading branch information
pan93412 authored Apr 23, 2022
1 parent f88addc commit ab85c51
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/utils/Player.js
Original file line number Diff line number Diff line change
@@ -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 { getPlaylistDetail, intelligencePlaylist } from '@/api/playlist';
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 { isAccountLoggedIn } from '@/utils/auth';
import { trackUpdateNowPlaying, trackScrobble } from '@/api/lastfm';
import { cacheTrackSource, getTrackSource } from '@/utils/db';
import { isCreateMpris, isCreateTray } from '@/utils/platform';
import { Howl, Howler } from 'howler';
import shuffle from 'lodash/shuffle';

const PLAY_PAUSE_FADE_DURATION = 200;

Expand Down Expand Up @@ -69,7 +69,9 @@ export default class {
this._playNextList = []; // 当这个list不为空时,会优先播放这个list的歌
this._isPersonalFM = false; // 是否是私人FM模式
this._personalFMTrack = { id: 0 }; // 私人FM当前歌曲
this._personalFMNextTrack = { id: 0 }; // 私人FM下一首歌曲信息(为了快速加载下一首)
this._personalFMNextTrack = {
id: 0,
}; // 私人FM下一首歌曲信息(为了快速加载下一首)

/**
* The blob records for cleanup.
Expand Down Expand Up @@ -192,8 +194,6 @@ export default class {

_init() {
this._loadSelfFromLocalStorage();
Howler.autoUnlock = false;
Howler.usingWebAudio = true;
Howler.volume(this.volume);

if (this._enabled) {
Expand Down Expand Up @@ -227,7 +227,8 @@ export default class {
}
_setIntervals() {
// 同步播放进度
// TODO: 如果 _progress 在别的地方被改变了,这个定时器会覆盖之前改变的值,是bug
// TODO: 如果 _progress 在别的地方被改变了,
// 这个定时器会覆盖之前改变的值,是bug
setInterval(() => {
if (this._howler === null) return;
this._progress = this._howler.seek();
Expand Down Expand Up @@ -313,6 +314,7 @@ export default class {
this._howler = new Howl({
src: [source],
html5: true,
preload: true,
format: ['mp3', 'flac'],
onend: () => {
this._nextTrackCallback();
Expand Down

0 comments on commit ab85c51

Please sign in to comment.