|
|
@ -11,6 +11,8 @@ import { isAccountLoggedIn } from '@/utils/auth';
|
|
|
|
import { trackUpdateNowPlaying, trackScrobble } from '@/api/lastfm';
|
|
|
|
import { trackUpdateNowPlaying, trackScrobble } from '@/api/lastfm';
|
|
|
|
import { isCreateMpris, isCreateTray } from '@/utils/platform';
|
|
|
|
import { isCreateMpris, isCreateTray } from '@/utils/platform';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PLAY_PAUSE_FADE_DURATION = 200;
|
|
|
|
|
|
|
|
|
|
|
|
const electron =
|
|
|
|
const electron =
|
|
|
|
process.env.IS_ELECTRON === true ? window.require('electron') : null;
|
|
|
|
process.env.IS_ELECTRON === true ? window.require('electron') : null;
|
|
|
|
const ipcRenderer =
|
|
|
|
const ipcRenderer =
|
|
|
@ -649,14 +651,23 @@ export default class {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pause() {
|
|
|
|
pause() {
|
|
|
|
|
|
|
|
this._howler?.fade(this.volume, 0, PLAY_PAUSE_FADE_DURATION);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._howler?.once('fade', () => {
|
|
|
|
this._howler?.pause();
|
|
|
|
this._howler?.pause();
|
|
|
|
this._setPlaying(false);
|
|
|
|
this._setPlaying(false);
|
|
|
|
setTitle(null);
|
|
|
|
setTitle(null);
|
|
|
|
this._pauseDiscordPresence(this._currentTrack);
|
|
|
|
this._pauseDiscordPresence(this._currentTrack);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
play() {
|
|
|
|
play() {
|
|
|
|
if (this._howler?.playing()) return;
|
|
|
|
if (this._howler?.playing()) return;
|
|
|
|
|
|
|
|
|
|
|
|
this._howler?.play();
|
|
|
|
this._howler?.play();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._howler?.once('play', () => {
|
|
|
|
|
|
|
|
this._howler?.fade(0, this.volume, PLAY_PAUSE_FADE_DURATION);
|
|
|
|
|
|
|
|
|
|
|
|
this._setPlaying(true);
|
|
|
|
this._setPlaying(true);
|
|
|
|
if (this._currentTrack.name) {
|
|
|
|
if (this._currentTrack.name) {
|
|
|
|
setTitle(this._currentTrack);
|
|
|
|
setTitle(this._currentTrack);
|
|
|
@ -671,6 +682,7 @@ export default class {
|
|
|
|
duration: ~~(this.currentTrack.dt / 1000),
|
|
|
|
duration: ~~(this.currentTrack.dt / 1000),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
playOrPause() {
|
|
|
|
playOrPause() {
|
|
|
|
if (this._howler?.playing()) {
|
|
|
|
if (this._howler?.playing()) {
|
|
|
|