|
|
@ -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,28 +651,38 @@ export default class {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pause() {
|
|
|
|
pause() {
|
|
|
|
this._howler?.pause();
|
|
|
|
this._howler?.fade(this.volume, 0, PLAY_PAUSE_FADE_DURATION);
|
|
|
|
this._setPlaying(false);
|
|
|
|
|
|
|
|
setTitle(null);
|
|
|
|
this._howler?.once('fade', () => {
|
|
|
|
this._pauseDiscordPresence(this._currentTrack);
|
|
|
|
this._howler?.pause();
|
|
|
|
|
|
|
|
this._setPlaying(false);
|
|
|
|
|
|
|
|
setTitle(null);
|
|
|
|
|
|
|
|
this._pauseDiscordPresence(this._currentTrack);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
play() {
|
|
|
|
play() {
|
|
|
|
if (this._howler?.playing()) return;
|
|
|
|
if (this._howler?.playing()) return;
|
|
|
|
|
|
|
|
|
|
|
|
this._howler?.play();
|
|
|
|
this._howler?.play();
|
|
|
|
this._setPlaying(true);
|
|
|
|
|
|
|
|
if (this._currentTrack.name) {
|
|
|
|
this._howler?.once('play', () => {
|
|
|
|
setTitle(this._currentTrack);
|
|
|
|
this._howler?.fade(0, this.volume, PLAY_PAUSE_FADE_DURATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._playDiscordPresence(this._currentTrack, this.seek());
|
|
|
|
this._setPlaying(true);
|
|
|
|
if (store.state.lastfm.key !== undefined) {
|
|
|
|
if (this._currentTrack.name) {
|
|
|
|
trackUpdateNowPlaying({
|
|
|
|
setTitle(this._currentTrack);
|
|
|
|
artist: this.currentTrack.ar[0].name,
|
|
|
|
}
|
|
|
|
track: this.currentTrack.name,
|
|
|
|
this._playDiscordPresence(this._currentTrack, this.seek());
|
|
|
|
album: this.currentTrack.al.name,
|
|
|
|
if (store.state.lastfm.key !== undefined) {
|
|
|
|
trackNumber: this.currentTrack.no,
|
|
|
|
trackUpdateNowPlaying({
|
|
|
|
duration: ~~(this.currentTrack.dt / 1000),
|
|
|
|
artist: this.currentTrack.ar[0].name,
|
|
|
|
});
|
|
|
|
track: this.currentTrack.name,
|
|
|
|
}
|
|
|
|
album: this.currentTrack.al.name,
|
|
|
|
|
|
|
|
trackNumber: this.currentTrack.no,
|
|
|
|
|
|
|
|
duration: ~~(this.currentTrack.dt / 1000),
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
playOrPause() {
|
|
|
|
playOrPause() {
|
|
|
|
if (this._howler?.playing()) {
|
|
|
|
if (this._howler?.playing()) {
|
|
|
|