diff --git a/package.json b/package.json index f2eaa78d..06b287ac 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,10 @@ "start:win32": "yarn build && set ELECTRON_ENABLE_LOGGING=true && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", "start:linux": "yarn build && ELECTRON_ENABLE_LOGGING=true && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", "start:darwin": "yarn build && ELECTRON_ENABLE_LOGGING=true && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", + "start-renderer": "run-script-os", + "start-renderer:win32": "set ELECTRON_ENABLE_LOGGING=true && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", + "start-renderer:linux": "ELECTRON_ENABLE_LOGGING=true && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", + "start-renderer:darwin": "ELECTRON_ENABLE_LOGGING=true && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", "pack": "electron-builder --dir", "dist": "yarn build && electron-builder", "dist:macarm": "yarn build && electron-builder --mac --arm64", diff --git a/src/i18n/README.md b/src/i18n/README.md index f474d134..6552894c 100644 --- a/src/i18n/README.md +++ b/src/i18n/README.md @@ -116,3 +116,9 @@ Update 12/02/2022 12:00 UTC * `settings.notyf.visual.theme.install.error`: Added for `en_US`. * `term.defaultPresets`: Added for `en_US`. * `term.userPresets`: Added for `en_US`. + +Update 16/02/2022 21:45 UTC + +* `term.audioControls`: Added for `en_US`. +* `settings.option.audio.volumeStep`: Added for `en_US`. +* `settings.option.audio.maxVolume`: Added for `en_US`.` \ No newline at end of file diff --git a/src/i18n/en_US.jsonc b/src/i18n/en_US.jsonc index 6f09a2fc..037cbe9c 100644 --- a/src/i18n/en_US.jsonc +++ b/src/i18n/en_US.jsonc @@ -109,6 +109,7 @@ "term.fullscreenView": "Fullscreen View", "term.defaultView": "Default View", "term.audioSettings": "Audio Settings", + "term.audioControls": "Audio Controls", "term.clearAll": "Clear All", "term.recentStations": "Recent Stations", "term.language": "Language", @@ -251,6 +252,8 @@ // Settings - Audio "settings.header.audio": "Audio", "settings.header.audio.description": "Adjust the audio settings for Cider.", + "settings.option.audio.volumeStep": "Volume Step", + "settings.option.audio.maxVolume": "Max Volume", "settings.option.audio.quality": "Audio Quality", // Dropdown "settings.header.audio.quality.hireslossless": "Hi-Res Lossless", "settings.header.audio.quality.hireslossless.description": "up to 24-bit/192 kHz", diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index cbe6547d..a586b662 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -53,6 +53,7 @@ export class BrowserWindow { "components/sidebar-playlist", "components/spatial-properties", "components/audio-settings", + "components/audio-controls", "components/qrcode-modal", "components/equalizer", "components/add-to-playlist", diff --git a/src/main/index.ts b/src/main/index.ts index 7038f483..daeb3eeb 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -69,6 +69,10 @@ ipcMain.on('nowPlayingItemDidChange', (_event, attributes) => { CiderPlug.callPlugins('onNowPlayingItemDidChange', attributes); }); +ipcMain.on('nowPlayingItemDidChangeLastFM', (_event, attributes) => { + CiderPlug.callPlugin('lastfm', 'nowPlayingItemDidChangeLastFM', attributes); +}) + app.on('before-quit', () => { CiderPlug.callPlugins('onBeforeQuit'); console.warn(`${app.getName()} exited.`); diff --git a/src/main/plugins/lastfm.ts b/src/main/plugins/lastfm.ts index 6110ad31..a7433b8b 100644 --- a/src/main/plugins/lastfm.ts +++ b/src/main/plugins/lastfm.ts @@ -79,46 +79,47 @@ export default class LastFMPlugin { } private scrobbleSong(attributes: any) { - if(this._timer) clearTimeout(this._timer); + if (this._timer) clearTimeout(this._timer); var self = this; this._timer = setTimeout(async () => { - const currentAttributes = attributes; + const currentAttributes = attributes; - if (!self._lastfm || self._lastfm.cachedAttributes === attributes) { - return - } + if (!self._lastfm || self._lastfm.cachedAttributes === attributes) { + return + } - if (self._lastfm.cachedAttributes) { - if (self._lastfm.cachedAttributes.playParams.id === attributes.playParams.id) return; - } + if (self._lastfm.cachedAttributes) { + if (self._lastfm.cachedAttributes.playParams.id === attributes.playParams.id) return; + } - const artist = await this.getPrimaryArtist(attributes) + const artist = await this.getPrimaryArtist(attributes) - if (currentAttributes.status && currentAttributes === attributes) { - if (fs.existsSync(this.sessionPath)) { - // Scrobble playing song. - if (attributes.status === true) { - self._lastfm.track.scrobble({ - 'artist': artist, - 'track': attributes.name, - 'album': attributes.albumName, - 'albumArtist': artist, - 'timestamp': new Date().getTime() / 1000 - }, function (err: any, scrobbled: any) { - if (err) { - return console.error('[LastFM] An error occurred while scrobbling', err); - } + if (currentAttributes.status && currentAttributes === attributes) { + if (fs.existsSync(this.sessionPath)) { + // Scrobble playing song. + if (attributes.status === true) { + self._lastfm.track.scrobble({ + 'artist': artist, + 'track': attributes.name, + 'album': attributes.albumName, + 'albumArtist': artist, + 'timestamp': new Date().getTime() / 1000 + }, function (err: any, scrobbled: any) { + if (err) { + return console.error('[LastFM] An error occurred while scrobbling', err); + } - console.log('[LastFM] Successfully scrobbled: ', scrobbled); - }); - self._lastfm.cachedAttributes = attributes + console.log('[LastFM] Successfully scrobbled: ', scrobbled); + }); + self._lastfm.cachedAttributes = attributes + } + } else { + self.authenticate(); } } else { - self.authenticate(); + return console.log('[LastFM] Did not add ', attributes.name, '—', artist, 'because now playing a other song.'); } - } else { - return console.log('[LastFM] Did not add ', attributes.name, '—', artist, 'because now playing a other song.'); - }},Math.round(attributes.durationInMillis * (self._store.lastfm.scrobble_after / 100))); + }, Math.round(attributes.durationInMillis * (self._store.lastfm.scrobble_after / 100))); } private async updateNowPlayingSong(attributes: any) { @@ -155,7 +156,7 @@ export default class LastFMPlugin { } } - private async getPrimaryArtist (attributes: any) { + private async getPrimaryArtist(attributes: any) { const songId = attributes.playParams.catalogId || attributes.playParams.id if (!this._store.lastfm.enabledRemoveFeaturingArtists || !songId) return attributes.artistName; @@ -258,19 +259,21 @@ export default class LastFMPlugin { */ onPlaybackStateDidChange(attributes: object): void { this.updateNowPlayingSong(attributes) - this.scrobbleSong(attributes) + // this.scrobbleSong(attributes) } /** * Runs on song change * @param attributes Music Attributes */ - onNowPlayingItemDidChange(attributes: object): void { - if (!this._store.lastfm.filterLoop){ + nowPlayingItemDidChangeLastFM(attributes: any): void { + attributes.status = true + if (!this._store.lastfm.filterLoop) { this._lastfm.cachedNowPlayingAttributes = false; - this._lastfm.cachedAttributes = false} - this.updateNowPlayingSong(attributes) - this.scrobbleSong(attributes) + this._lastfm.cachedAttributes = false + } + this.updateNowPlayingSong(attributes) + this.scrobbleSong(attributes) } } diff --git a/src/preload/cider-preload.js b/src/preload/cider-preload.js index bf6f2924..50e4d1ee 100644 --- a/src/preload/cider-preload.js +++ b/src/preload/cider-preload.js @@ -7,9 +7,10 @@ let cache = {playParams: {id: 0}, status: null, remainingTime: 0}, const MusicKitInterop = { init: function () { MusicKit.getInstance().addEventListener(MusicKit.Events.playbackStateDidChange, () => { - if (MusicKitInterop.filterTrack(MusicKitInterop.getAttributes(), true, false)) { - global.ipcRenderer.send('playbackStateDidChange', MusicKitInterop.getAttributes()) - ipcRenderer.send('wsapi-updatePlaybackState', MusicKitInterop.getAttributes()); + const attributes = MusicKitInterop.getAttributes() + if (MusicKitInterop.filterTrack(attributes, true, false)) { + global.ipcRenderer.send('playbackStateDidChange', attributes) + ipcRenderer.send('wsapi-updatePlaybackState', attributes); // if (typeof _plugins != "undefined") { // _plugins.execute("OnPlaybackStateChanged", {Attributes: MusicKitInterop.getAttributes()}) // } @@ -23,9 +24,17 @@ const MusicKitInterop = { /** wsapi */ MusicKit.getInstance().addEventListener(MusicKit.Events.nowPlayingItemDidChange, async () => { + const attributes = MusicKitInterop.getAttributes() + const trackFilter = MusicKitInterop.filterTrack(attributes, false, true) + + if (trackFilter) { + global.ipcRenderer.send('nowPlayingItemDidChange', attributes); + } + + // LastFM's Custom Call // await MusicKitInterop.modifyNamesOnLocale(); - if (MusicKitInterop.filterTrack(MusicKitInterop.getAttributes(), false, true) || !app.cfg.lastfm.filterLoop) { - global.ipcRenderer.send('nowPlayingItemDidChange', MusicKitInterop.getAttributes()); + if (trackFilter || !app.cfg.lastfm.filterLoop) { + global.ipcRenderer.send('nowPlayingItemDidChangeLastFM', attributes); } }); @@ -67,7 +76,7 @@ const MusicKitInterop = { const attributes = (nowPlayingItem != null ? nowPlayingItem.attributes : {}); attributes.status = isPlayingExport ?? false; - attributes.name = attributes?.name ?? 'No Title Found'; + attributes.name = attributes?.name ?? 'no-title-found'; attributes.artwork = attributes?.artwork ?? {url: ''}; attributes.artwork.url = (attributes?.artwork?.url ?? '').replace(`{f}`, "png"); attributes.playParams = attributes?.playParams ?? {id: 'no-id-found'}; @@ -96,7 +105,7 @@ const MusicKitInterop = { }, filterTrack: function (a, playbackCheck, mediaCheck) { - if (a.title === "No Title Found" || a.playParams.id === "no-id-found") { + if (a.name === 'no-title-found' || a.playParams.id === "no-id-found") { return; } else if (mediaCheck && a.playParams.id === cache.playParams.id) { return; diff --git a/src/renderer/index.js b/src/renderer/index.js index c2aee7ac..7daf7bb8 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -233,6 +233,7 @@ const app = new Vue({ qrcode: false, equalizer: false, audioSettings: false, + audioControls: false, showPlaylist: false, }, socialBadges: { @@ -272,7 +273,7 @@ const app = new Vue({ artistPage: () => { document.getElementById("app-content").scrollTo(0, 0); app.resetState() - }, + } }, methods: { songLinkShare(amUrl) { @@ -3321,7 +3322,7 @@ const app = new Vue({ console.log('setting max volume') } else { console.log('volume up') - app.mk.volume += app.cfg.audio.volumeStep; + app.mk.volume = ((app.mk.volume * 100) + (app.cfg.audio.volumeStep * 100)) / 100 } }, volumeDown() { @@ -3330,11 +3331,11 @@ const app = new Vue({ console.log('setting volume to 0') } else { console.log('volume down') - app.mk.volume -= app.cfg.audio.volumeStep; + app.mk.volume = ((app.mk.volume * 100) - (app.cfg.audio.volumeStep * 100)) / 100 } }, volumeWheel(event) { - app.checkScrollDirectionIsUp(event) ? app.volumeUp() : app.volumeDown() + app.checkScrollDirectionIsUp(event) ? this.volumeUp() : this.volumeDown() }, muteButtonPressed() { if (this.cfg.audio.muted) { diff --git a/src/renderer/style.less b/src/renderer/style.less index 9df52a9b..4b4d957c 100644 --- a/src/renderer/style.less +++ b/src/renderer/style.less @@ -3134,5 +3134,25 @@ body[platform='darwin'] { } } +.percent { + display: inline-block; + position: relative; +} + +.percent::after { + position: relative; + right: 2em; + transition: all .05s ease-in-out; +} + +.percent:hover::after, +.percent:focus-within::after { + right: 3.5em; +} + +.percent::after { + content: '%'; +} + @import url("less/compact.less"); diff --git a/src/renderer/views/app/panels.ejs b/src/renderer/views/app/panels.ejs index af2b76f9..85227a31 100644 --- a/src/renderer/views/app/panels.ejs +++ b/src/renderer/views/app/panels.ejs @@ -16,6 +16,9 @@ + + + diff --git a/src/renderer/views/app/sidebar.ejs b/src/renderer/views/app/sidebar.ejs index 4cae1592..fbad26eb 100644 --- a/src/renderer/views/app/sidebar.ejs +++ b/src/renderer/views/app/sidebar.ejs @@ -152,7 +152,7 @@
- diff --git a/src/renderer/views/components/audio-controls.ejs b/src/renderer/views/components/audio-controls.ejs new file mode 100644 index 00000000..57a174e6 --- /dev/null +++ b/src/renderer/views/components/audio-controls.ejs @@ -0,0 +1,87 @@ + + + \ No newline at end of file diff --git a/src/renderer/views/components/audio-settings.ejs b/src/renderer/views/components/audio-settings.ejs index 512db50e..aadab781 100644 --- a/src/renderer/views/components/audio-settings.ejs +++ b/src/renderer/views/components/audio-settings.ejs @@ -17,6 +17,11 @@
<%- include("../svg/speaker.svg") %>
{{app.getLz('settings.option.audio.enableAdvancedFunctionality.audioSpatialization')}}
+
@@ -46,6 +51,10 @@ notyf.error(app.getLz('spatial.notTurnedOn')) } }, + openAudioControls() { + app.modals.audioControls = true + app.modals.audioSettings = false + } } }); \ No newline at end of file diff --git a/src/renderer/views/components/fullscreen.ejs b/src/renderer/views/components/fullscreen.ejs index 733a4b0c..6572ff97 100644 --- a/src/renderer/views/components/fullscreen.ejs +++ b/src/renderer/views/components/fullscreen.ejs @@ -80,7 +80,7 @@
-
diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 23292ff0..32a50e46 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -42,6 +42,16 @@ +
+
+ {{$root.getLz('term.audioControls')}} +
+
+ +
+
{{$root.getLz('settings.option.audio.seamlessTransition')}}