From eaaee7a36172b033e2fec45707390dce43486640 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Thu, 21 Apr 2022 21:43:38 +0200 Subject: [PATCH 01/27] Create basic modal --- src/renderer/style.css | 7 ++++ src/renderer/style.less | 8 ++++ src/renderer/views/pages/settings.ejs | 54 +++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/src/renderer/style.css b/src/renderer/style.css index 42702b6e..fbfe6743 100644 --- a/src/renderer/style.css +++ b/src/renderer/style.css @@ -12826,6 +12826,13 @@ body.no-gpu .drawertransition-leave-to { body.no-gpu .lyric-line:hover::after { display: none; } +.keybindings-border { + padding-left: 15px; + padding-right: 15px; + border-style: solid; + border-radius: 5px; + border-color: #CBCBCB; +} .qrimg { width: -webkit-fill-available; max-block-size: -webkit-fill-available; diff --git a/src/renderer/style.less b/src/renderer/style.less index 80934d6f..ff98f58a 100644 --- a/src/renderer/style.less +++ b/src/renderer/style.less @@ -3123,6 +3123,14 @@ body.no-gpu { } } +.keybindings-border { + padding-left: 15px; + padding-right: 15px; + border-style: solid; + border-radius: 5px; + border-color: #CBCBCB; +} + .qrimg { width: -webkit-fill-available; max-block-size: -webkit-fill-available; diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index e72a036a..c3e70599 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -123,6 +123,60 @@ +
+
+ {{$root.getLz('settings.option.general.customizeSidebar')}} +
+
+ +
+ +
+
+
+ Web Remote +
+
+

CTRL + Shift + W

+
+
+
+
+ Audio Settings +
+
+

CTRL + Shift + A

+
+
+
+
+ Plugin Menu +
+
+

CTRL + Shift + P

+
+
+
+
+ Cast to Devices +
+
+

CTRL + Shift + C

+
+
+
+
+ Open Developer Tools +
+
+

CTRL + Shift + I

+
+
+
+
+
From 2c8dfdc3693f9f742ee7fbce76b04a77d8666540 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Thu, 21 Apr 2022 21:48:27 +0200 Subject: [PATCH 02/27] Create i18n strings --- src/i18n/README.md | 5 +++++ src/i18n/en_US.json | 2 ++ src/i18n/source/en_US.json | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/i18n/README.md b/src/i18n/README.md index c4220aa0..eb18409e 100644 --- a/src/i18n/README.md +++ b/src/i18n/README.md @@ -258,3 +258,8 @@ Update 16/04/2022 9:30 UTC * `settings.header.connect`: Added for `en_US` +Update 21/04/2022 20:00 UTC + +* `settings.option.general.keybindings`: Added for `en_US` +* `settings.option.general.keybindings.open`: Added for `en_US` + diff --git a/src/i18n/en_US.json b/src/i18n/en_US.json index 3b92951b..a53175aa 100644 --- a/src/i18n/en_US.json +++ b/src/i18n/en_US.json @@ -279,6 +279,8 @@ "settings.option.general.updateCider.branch.develop": "Development", "settings.option.general.customizeSidebar": "Customize Sidebar Items", "settings.option.general.customizeSidebar.customize": "Customize", + "settings.option.general.keybindings": "Keybindings", + "settings.option.general.keybindings.open": "Open", "settings.notyf.updateCider.update-not-available": "No update available", "settings.notyf.updateCider.update-downloaded": "Update has been downloaded, restart to apply", "settings.notyf.updateCider.update-error": "Error updating Cider", diff --git a/src/i18n/source/en_US.json b/src/i18n/source/en_US.json index 2d5f4bf5..f0432330 100644 --- a/src/i18n/source/en_US.json +++ b/src/i18n/source/en_US.json @@ -279,6 +279,8 @@ "settings.option.general.updateCider.branch.develop": "Development", "settings.option.general.customizeSidebar": "Customize Sidebar Items", "settings.option.general.customizeSidebar.customize": "Customize", + "settings.option.general.keybindings": "Keybindings", + "settings.option.general.keybindings.open": "Open", "settings.notyf.updateCider.update-not-available": "No update available", "settings.notyf.updateCider.update-downloaded": "Update has been downloaded, restart to apply", "settings.notyf.updateCider.update-error": "Error updating Cider", From dd9d1d0fbdcee35723a2ede3db7ee27a82f8e5cb Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Thu, 21 Apr 2022 21:49:16 +0200 Subject: [PATCH 03/27] Use new i18n strings --- src/renderer/views/pages/settings.ejs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index c3e70599..75fb9ee2 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -125,14 +125,14 @@
- {{$root.getLz('settings.option.general.customizeSidebar')}} + {{$root.getLz('settings.option.general.keybindings')}}
- +
From 0547ecf014aa0908e0d8f3ea838d77ac0921c300 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Thu, 21 Apr 2022 22:22:00 +0200 Subject: [PATCH 04/27] Align rectangels --- src/renderer/style.css | 3 +++ src/renderer/style.less | 4 ++++ src/renderer/views/pages/settings.ejs | 10 +++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/renderer/style.css b/src/renderer/style.css index fbfe6743..3b988439 100644 --- a/src/renderer/style.css +++ b/src/renderer/style.css @@ -12833,6 +12833,9 @@ body.no-gpu .lyric-line:hover::after { border-radius: 5px; border-color: #CBCBCB; } +.keybinding-text { + width: 110px; +} .qrimg { width: -webkit-fill-available; max-block-size: -webkit-fill-available; diff --git a/src/renderer/style.less b/src/renderer/style.less index ff98f58a..b5b01bd8 100644 --- a/src/renderer/style.less +++ b/src/renderer/style.less @@ -3131,6 +3131,10 @@ body.no-gpu { border-color: #CBCBCB; } +.keybinding-text { + width: 110px; +} + .qrimg { width: -webkit-fill-available; max-block-size: -webkit-fill-available; diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 75fb9ee2..98772e1e 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -139,7 +139,7 @@ Web Remote
-

CTRL + Shift + W

+

CTRL + Shift + W

@@ -147,7 +147,7 @@ Audio Settings
-

CTRL + Shift + A

+

CTRL + Shift + A

@@ -155,7 +155,7 @@ Plugin Menu
-

CTRL + Shift + P

+

CTRL + Shift + P

@@ -163,7 +163,7 @@ Cast to Devices
-

CTRL + Shift + C

+

CTRL + Shift + C

@@ -171,7 +171,7 @@ Open Developer Tools
-

CTRL + Shift + I

+

CTRL + Shift + I

From 929a52179545d7dc9b27bbfe0cd5fc9382a54218 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Thu, 21 Apr 2022 22:31:30 +0200 Subject: [PATCH 05/27] Create getCommandOrControl function --- src/renderer/views/pages/settings.ejs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 98772e1e..b9f3c6f4 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -134,6 +134,7 @@
+
Web Remote @@ -1178,6 +1179,9 @@ } }, methods: { + getCommandOrControl() { + return app.cfg.os == "darwin" ? "⌘" : "Ctrl"; + }, windowBgStyleChange() { this.$root.getNowPlayingArtworkBG(undefined, true) if (this.$root.cfg.visual.window_background_style == "mica") { From 186e6986ef097d15a1e614a8d34dfae82f29f3c8 Mon Sep 17 00:00:00 2001 From: child_duckling <19170969+quacksire@users.noreply.github.com> Date: Thu, 21 Apr 2022 21:28:07 -0700 Subject: [PATCH 06/27] [connect] Fixed webview, now why no theme? --- src/main/base/browserwindow.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index 371aaed4..7af9dcba 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -528,6 +528,7 @@ export class BrowserWindow { app.get("/connect/set-cc-user/:data", (req, res) => { //utils.getStoreValue('connectUser', JSON.parse()) // [Connect] Save user in store utils.setStoreValue('connectUser', JSON.parse(req.params.data)) + utils.getWindow().reload() res.redirect(`https://connect.cidercollective.dev/linked.html`) }); // [Connect] Set auth URL in store for `shell.openExternal` From 1eb70568af19b91ffb3ba3d7c48ab3de105a62b3 Mon Sep 17 00:00:00 2001 From: child_duckling <19170969+quacksire@users.noreply.github.com> Date: Thu, 21 Apr 2022 22:04:34 -0700 Subject: [PATCH 07/27] [connect] theme still not working, but app no crash on startup --- src/main/base/store.ts | 5 ++++- src/renderer/less/pages.less | 4 ++++ src/renderer/views/pages/settings.ejs | 8 +++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/base/store.ts b/src/main/base/store.ts index e06ec8f6..8a6b999c 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -155,7 +155,10 @@ export class Store { "AudioContext": false, "experiments": [], "playlistTrackMapping": true - } + }, + "connectUser": { + "auth": null, + }, } private migrations: any = { '>=1.4.3': (store: ElectronStore) => { diff --git a/src/renderer/less/pages.less b/src/renderer/less/pages.less index 38d9e51b..66c68f19 100644 --- a/src/renderer/less/pages.less +++ b/src/renderer/less/pages.less @@ -1149,6 +1149,10 @@ font-size : 2em; } + .settings-option-body-webview { + height: 100%; + width: 100%; + } .settings-option-body { margin: 16px; } diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 0910eb61..c5d44ac3 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -982,8 +982,8 @@
{{$root.getLz('settings.header.connect')}}
-
-
+
+
{{$root.getLz('settings.option.connect.link_account')}} {{$root.getLz('settings.option.connect.link_account.description')}} @@ -996,9 +996,11 @@
+
+ +
-
From d8aca925f48fa6c2d57fce93e4c80cbd386f74f7 Mon Sep 17 00:00:00 2001 From: yazninja Date: Fri, 22 Apr 2022 15:02:20 +0800 Subject: [PATCH 08/27] js++ oops --- src/main/plugins/sendSongToTitlebar.ts | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/plugins/sendSongToTitlebar.ts diff --git a/src/main/plugins/sendSongToTitlebar.ts b/src/main/plugins/sendSongToTitlebar.ts new file mode 100644 index 00000000..c8e3a62c --- /dev/null +++ b/src/main/plugins/sendSongToTitlebar.ts @@ -0,0 +1,37 @@ +export default class sendSongToTitlebar { + /** + * Base Plugin Details (Eventually implemented into a GUI in settings) + */ + public name: string = 'sendSongToTitlebar'; + public description: string = 'Sets the app\'s titlebar to the Song title'; + public version: string = '0.0.1'; + public author: string = 'Cider Collective (credit to 8times9 via #147)'; + /** + * Runs on plugin load (Currently run on application start) + */ + private _win: any; + private _app: any; + constructor() {} + /** + * Runs on app ready + */ + onReady(win: any): void { + this._win = win; + } + /** + * Runs on app stop + */ + onBeforeQuit(): void {} + /** + * Runs on playback State Change + * @param attributes Music Attributes (attributes.status = current state) + */ + onPlaybackStateDidChange(attributes: any): void { + this._win.setTitle(`${(attributes != null && attributes.name != null && attributes.name.length > 0) ? (attributes.name + " - ") : ''}Cider`) + } + /** + * Runs on song change + * @param attributes Music Attributes + */ + onNowPlayingItemDidChange(attributes: object): void {} +} \ No newline at end of file From b9db26a846ff6399dd5302084acb38ca251f4bd0 Mon Sep 17 00:00:00 2001 From: yazninja Date: Fri, 22 Apr 2022 15:52:06 +0800 Subject: [PATCH 09/27] add musicVideo Icon to distinguish MVs --- src/renderer/style.less | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/renderer/style.less b/src/renderer/style.less index 80934d6f..fc6daf29 100644 --- a/src/renderer/style.less +++ b/src/renderer/style.less @@ -1228,6 +1228,18 @@ body[platform="darwin"] .app-chrome .app-chrome-item > .window-controls > div.cl margin-bottom: 15px; } } +// Add Music Video Icons to Songs that are Music Videos +div[data-type="library-music-videos"] .info-rect .title::before, +div[data-type="musicVideo"] .info-rect .title::before { + content: ""; + background-image: url(./assets/feather/video.svg); + background-size: contain; + filter:invert(0.6); + display: inline-block; + width: 20px; + height: 20px; + margin-bottom: -4px; +} .app-chrome .app-chrome-item > .app-playback-controls .song-duration p { font-weight: 400; From 3143a3cd14e471db00c555e735ad072691a7c0c8 Mon Sep 17 00:00:00 2001 From: yazninja Date: Fri, 22 Apr 2022 15:52:36 +0800 Subject: [PATCH 10/27] wait i thought i fixed this? --- src/main/plugins/menubar.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/plugins/menubar.ts b/src/main/plugins/menubar.ts index 33caae52..b2e7caba 100644 --- a/src/main/plugins/menubar.ts +++ b/src/main/plugins/menubar.ts @@ -121,7 +121,7 @@ export default class Thumbar { }, { label: 'Plug-in Menu', - accelerator: 'CommandOrControl++Shift+P', + accelerator: 'CommandOrControl+Shift+P', click: () => this._win.webContents.executeJavaScript(`app.modals.pluginMenu = true`) } From d31f044d606db2d598dda2748c6948e975855328 Mon Sep 17 00:00:00 2001 From: yazninja Date: Fri, 22 Apr 2022 15:55:40 +0800 Subject: [PATCH 11/27] Revert "js++ oops" This reverts commit d8aca925f48fa6c2d57fce93e4c80cbd386f74f7. --- src/main/plugins/sendSongToTitlebar.ts | 37 -------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/main/plugins/sendSongToTitlebar.ts diff --git a/src/main/plugins/sendSongToTitlebar.ts b/src/main/plugins/sendSongToTitlebar.ts deleted file mode 100644 index c8e3a62c..00000000 --- a/src/main/plugins/sendSongToTitlebar.ts +++ /dev/null @@ -1,37 +0,0 @@ -export default class sendSongToTitlebar { - /** - * Base Plugin Details (Eventually implemented into a GUI in settings) - */ - public name: string = 'sendSongToTitlebar'; - public description: string = 'Sets the app\'s titlebar to the Song title'; - public version: string = '0.0.1'; - public author: string = 'Cider Collective (credit to 8times9 via #147)'; - /** - * Runs on plugin load (Currently run on application start) - */ - private _win: any; - private _app: any; - constructor() {} - /** - * Runs on app ready - */ - onReady(win: any): void { - this._win = win; - } - /** - * Runs on app stop - */ - onBeforeQuit(): void {} - /** - * Runs on playback State Change - * @param attributes Music Attributes (attributes.status = current state) - */ - onPlaybackStateDidChange(attributes: any): void { - this._win.setTitle(`${(attributes != null && attributes.name != null && attributes.name.length > 0) ? (attributes.name + " - ") : ''}Cider`) - } - /** - * Runs on song change - * @param attributes Music Attributes - */ - onNowPlayingItemDidChange(attributes: object): void {} -} \ No newline at end of file From 1f157ade289f64a4c181e4fc72d1e2202613dc31 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:45:54 +0200 Subject: [PATCH 12/27] Modal finished --- src/renderer/style.css | 5 ++++- src/renderer/style.less | 5 ++++- src/renderer/views/pages/settings.ejs | 20 ++++++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/renderer/style.css b/src/renderer/style.css index 3b988439..33e4b4db 100644 --- a/src/renderer/style.css +++ b/src/renderer/style.css @@ -12834,7 +12834,10 @@ body.no-gpu .lyric-line:hover::after { border-color: #CBCBCB; } .keybinding-text { - width: 110px; + width: 95px; + display: flex; + justify-content: center; + align-items: center; } .qrimg { width: -webkit-fill-available; diff --git a/src/renderer/style.less b/src/renderer/style.less index b5b01bd8..80344407 100644 --- a/src/renderer/style.less +++ b/src/renderer/style.less @@ -3132,7 +3132,10 @@ body.no-gpu { } .keybinding-text { - width: 110px; + width: 95px; + display: flex; + justify-content: center; + align-items: center; } .qrimg { diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index b9f3c6f4..e8876812 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -135,12 +135,20 @@
+
+
+ Toggle Private Session +
+
+

{{ getCommandOrControl() }} + P

+
+
Web Remote
-

CTRL + Shift + W

+

{{ getCommandOrControl() }} + Shift + W

@@ -148,7 +156,7 @@ Audio Settings
-

CTRL + Shift + A

+

{{ getCommandOrControl() }} + Shift + A

@@ -156,7 +164,7 @@ Plugin Menu
-

CTRL + Shift + P

+

{{ getCommandOrControl() }} + Shift + P

@@ -164,7 +172,7 @@ Cast to Devices
-

CTRL + Shift + C

+

{{ getCommandOrControl() }} + Shift + C

@@ -172,7 +180,7 @@ Open Developer Tools
-

CTRL + Shift + I

+

{{ getCommandOrControl() }} + Shift + I

@@ -1180,7 +1188,7 @@ }, methods: { getCommandOrControl() { - return app.cfg.os == "darwin" ? "⌘" : "Ctrl"; + return app.platform == "darwin" ? "⌘" : "Ctrl"; }, windowBgStyleChange() { this.$root.getNowPlayingArtworkBG(undefined, true) From 1e793cf172f2ac2f5e207ee5f18adae65fdc03bd Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Fri, 22 Apr 2022 11:48:57 +0200 Subject: [PATCH 13/27] Add ok-only to modal and remove comment --- src/renderer/views/pages/settings.ejs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index e8876812..ef4a90d9 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -132,9 +132,8 @@ {{$root.getLz('settings.option.general.keybindings.open')}} - +
-
Toggle Private Session From 6d75bf83fa97f5311ee641eba4f6720f60c83122 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:09:23 +0200 Subject: [PATCH 14/27] Add function for DevTools keys --- src/renderer/views/pages/settings.ejs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index bb7366e5..1de80810 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -179,7 +179,7 @@ Open Developer Tools
-

{{ getCommandOrControl() }} + Shift + I

+

{{ getCommandOrControl() }} + {{ getOptionOrShift() }} + I

@@ -1191,6 +1191,9 @@ getCommandOrControl() { return app.platform == "darwin" ? "⌘" : "Ctrl"; }, + getOptionOrShift() { + return app.platform == "darwin" ? "⌥" : "Shift"; + }, windowBgStyleChange() { this.$root.getNowPlayingArtworkBG(undefined, true) if (this.$root.cfg.visual.window_background_style == "mica") { From 1d9cefa7cd777303acb83bc0ccfe38be2c7418f1 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:10:36 +0200 Subject: [PATCH 15/27] Translate strings to Hungarian (hu_HU) --- src/i18n/hu_HU.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/i18n/hu_HU.json b/src/i18n/hu_HU.json index 1c42b123..5ebe3a07 100644 --- a/src/i18n/hu_HU.json +++ b/src/i18n/hu_HU.json @@ -279,6 +279,8 @@ "settings.option.general.updateCider.branch.develop": "Fejlesztői", "settings.option.general.customizeSidebar": "Oldalsáv elemeinek testreszabása", "settings.option.general.customizeSidebar.customize": "Testreszabás", + "settings.option.general.keybindings": "Billentyűparancsok", + "settings.option.general.keybindings.open": "Megnyitás", "settings.notyf.updateCider.update-not-available": "Nem található frissítés", "settings.notyf.updateCider.update-downloaded": "A frissítés le lett töltve, a telepítéshez indítsa újra az alkalmazást", "settings.notyf.updateCider.update-error": "Hiba történt a frissítés közben", From 63b58e99e96f3b1b1756f7bacb10b9015ba1b909 Mon Sep 17 00:00:00 2001 From: Amaru8 <52407090+Amaru8@users.noreply.github.com> Date: Fri, 22 Apr 2022 12:12:23 +0200 Subject: [PATCH 16/27] Update i18n README --- src/i18n/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/README.md b/src/i18n/README.md index c10275ec..eba2e4b7 100644 --- a/src/i18n/README.md +++ b/src/i18n/README.md @@ -262,7 +262,7 @@ Update 16/04/2022 9:30 UTC * `settings.header.connect`: Added for `en_US` -Update 21/04/2022 20:00 UTC +Update 22/04/2022 13:00 UTC * `settings.option.general.keybindings`: Added for `en_US` * `settings.option.general.keybindings.open`: Added for `en_US` From 8fddbb6a43eb11d52a4455b771753a31037f33b9 Mon Sep 17 00:00:00 2001 From: vapormusic Date: Sat, 23 Apr 2022 01:30:56 +0700 Subject: [PATCH 17/27] test 1 --- package.json | 5 +- src/main/base/store.ts | 3 +- src/main/plugins/raop.ts | 259 +++++++++++++++++++++ src/renderer/views/components/castmenu.ejs | 29 ++- src/renderer/views/pages/settings.ejs | 11 + 5 files changed, 301 insertions(+), 6 deletions(-) create mode 100644 src/main/plugins/raop.ts diff --git a/package.json b/package.json index 99046ccd..83f54bd5 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,11 @@ "@sentry/electron": "^3.0.7", "@sentry/integrations": "^6.19.6", "adm-zip": "0.4.10", + "airtunes2": "git+https://github.com/vapormusic/node_airtunes2.git", "castv2-client": "^1.2.0", "chokidar": "^3.5.3", "discord-rpc": "^4.0.1", + "dns-js": "git+https://github.com/ciderapp/node-dns-js.git", "ejs": "^3.1.6", "electron-fetch": "^1.7.4", "electron-log": "^4.4.6", @@ -52,7 +54,6 @@ "get-port": "^5.1.1", "jsonc": "^2.0.0", "lastfmapi": "^0.1.1", - "dns-js": "git+https://github.com/ciderapp/node-dns-js.git", "mdns-js": "git+https://github.com/ciderapp/node-mdns-js.git", "mpris-service": "^2.1.2", "music-metadata": "^7.12.3", @@ -70,11 +71,11 @@ "youtube-search-without-api-key": "^1.0.7" }, "devDependencies": { + "@types/adm-zip": "^0.5.0", "@types/discord-rpc": "4.0.2", "@types/express": "^4.17.13", "@types/qrcode-terminal": "^0.12.0", "@types/ws": "^8.5.3", - "@types/adm-zip": "^0.5.0", "electron": "git+https://github.com/castlabs/electron-releases.git", "electron-builder": "^23.0.3", "electron-builder-notarize-pkg": "^1.2.0", diff --git a/src/main/base/store.ts b/src/main/base/store.ts index 8a6b999c..3436d807 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -154,7 +154,8 @@ export class Store { "advanced": { "AudioContext": false, "experiments": [], - "playlistTrackMapping": true + "playlistTrackMapping": true, + "ffmpegLocation": "" }, "connectUser": { "auth": null, diff --git a/src/main/plugins/raop.ts b/src/main/plugins/raop.ts new file mode 100644 index 00000000..2273e686 --- /dev/null +++ b/src/main/plugins/raop.ts @@ -0,0 +1,259 @@ +import * as electron from 'electron'; +import * as os from 'os'; +import * as fs from 'fs'; +import { join, resolve } from 'path'; +import * as CiderReceiver from '../base/castreceiver'; +import fetch from 'electron-fetch'; +import {Stream} from "stream"; +import {spawn} from 'child_process'; + + +export default class RAOP { + + /** + * Private variables for interaction in plugins + */ + private _utils: any; + private _win: any; + private _app: any; + private _store: any; + private _cacheAttr: any; + + private ipairplay: any = ""; + private portairplay: any = ""; + private u = require('airtunes2'); + private airtunes: any; + private device: any; + private mdns = require('mdns-js'); + private ok: any = 1; + private devices: any = []; + private castDevices: any = []; + private i: any = false; + private audioStream: any = new Stream.PassThrough(); + private ffmpeg: any = null; + + private ondeviceup(name: any, host: any, port: any, addresses: any) { + if (this.castDevices.findIndex((item: any) => item.name === host && item.port === port && item.addresses === addresses) === -1) { + this.castDevices.push({ + name: host, + host: addresses ? addresses[0] : '', + port: port, + addresses: addresses + }); + if (this.devices.indexOf(host) === -1) { + this.devices.push(host); + } + if (name) { + this._win.webContents.executeJavaScript(`console.log('deviceFound','ip: ${host} name:${name}')`).catch((err: any) => console.error(err)); + console.log("deviceFound", host, name); + } + } else { + this._win.webContents.executeJavaScript(`console.log('deviceFound (added)','ip: ${host} name:${name}')`).catch((err: any) => console.error(err)); + console.log("deviceFound (added)", host, name); + } + } + + /** + * Base Plugin Details (Eventually implemented into a GUI in settings) + */ + public name: string = 'RAOP'; + public description: string = 'RAOP Plugin'; + public version: string = '0.0.1'; + public author: string = 'vapormusic / Cider Collective'; + + /** + * Runs on plugin load (Currently run on application start) + */ + constructor(utils: { getStore: () => any; getApp: () => any; }) { + this._utils = utils; + console.debug(`[Plugin][${this.name}] Loading Complete.`); + this._app = utils.getApp(); + + } + + /** + * Runs on app ready + */ + onReady(win: any): void { + this._win = win; + + electron.ipcMain.on('getKnownAirplayDevices', (event) => { + event.returnValue = this.castDevices + }); + + electron.ipcMain.on("getAirplayDevice", (event, data) => { + this.castDevices = []; + console.log("scan for airplay devices"); + + const browser = this.mdns.createBrowser(this.mdns.tcp('raop')); + browser.on('ready', browser.discover); + + browser.on('update', (service: any) => { + if (service.addresses && service.fullname && service.fullname.includes('_raop._tcp')) { + this._win.webContents.executeJavaScript(`console.log( + "${service.name} ${service.host}:${service.port} ${service.addresses}" + )`);} + this.ondeviceup(service.name, service.host, service.port, service.addresses); + }); + + }); + + + + electron.ipcMain.on("performAirplayPCM", (event, ipv4, ipport, sepassword, title, artist, album, artworkURL) => { + + if (ipv4 != this.ipairplay || ipport != this.portairplay) { + if (this.airtunes == null) { this.airtunes = new this.u()} + this.ipairplay = ipv4; + this.portairplay = ipport; + this.device = this.airtunes.add(ipv4, { + port: ipport, + volume: 60, + password: sepassword, + }); + this.device.on('status', (status: any) => { + console.log('device status', status); + if (status == "ready"){ + this._win.webContents.executeJavaScript(`CiderAudio.sendAudio()`).catch((err: any) => console.error(err)); + } + if (status == 'stopped') { + this.airtunes.stopAll(() => { + console.log('end'); + }); + this.airtunes = null; + this.device = null; + this.ipairplay = ''; + this.portairplay = ''; + this.ok = 1; + + } else { + setTimeout(() => { + if (this.ok == 1) { + console.log(this.device.key, title ?? '', artist ?? '', album ?? ''); + this.airtunes.setTrackInfo(this.device.key, title ?? '', artist?? '', album?? ''); + this.uploadImageAirplay(artworkURL); + console.log('done'); + this.ok == 2 + } + }, 1000); + } + + + }); + + } + + + + + }); + + electron.ipcMain.on('writeWAV', (event) => { + if (this.airtunes != null) { + if (!this.i){ + this.ffmpeg != null ? this.ffmpeg.kill() : null; + this.ffmpeg = spawn(this._utils.getStoreValue("advanced.ffmpegLocation"), [ + '-f', 's16le', // PCM 16bits, little-endian + '-ar', '48000', + '-ac', "2", + '-i', "http://localhost:9000/audio.wav", + '-acodec', 'pcm_s16le', + '-f', 's16le', // PCM 16bits, little-endian + '-ar', '44100', // Sampling rate + '-ac', "2", // Stereo + 'pipe:1' // Output on stdout + ]); + + // pipe data to AirTunes + this.ffmpeg.stdout.pipe(this.airtunes); + this.i = true;}} + + }); + + + + electron.ipcMain.on('disconnectAirplay', (event) => { + this.airtunes.stopAll(function () { + console.log('end'); + }); + this.airtunes = null; + this.device = null; + this.ipairplay = ''; + this.portairplay = ''; + this.ok = 1; + this.i = false; + }); + + electron.ipcMain.on('updateAirplayInfo', (event, title, artist, album, artworkURL) => { + if (this.airtunes && this.device) { + console.log(this.device.key, title, artist, album); + this.airtunes.setTrackInfo(this.device.key, title, artist, album); + this.uploadImageAirplay(artworkURL) + } + }); + + electron.ipcMain.on('updateRPCImage', (_event, imageurl) => { + this.uploadImageAirplay(imageurl) + }) + + + + } + + private uploadImageAirplay = (url: any) => { + try { + if (url != null && url != '') { + //console.log(join(this._app.getPath('userData'), 'temp.png'), url); + fetch(url) + .then(res => res.buffer()) + .then((buffer) => { + this.airtunes.setArtwork(this.device.key, buffer, "image/png"); + }).catch(err => { + console.log(err) + }); + } + } catch (e) { console.log(e) } + } + + /** + * Runs on app stop + */ + onBeforeQuit(): void { + + } + + // /** + // * Runs on song change + // * @param attributes Music Attributes + // */ + // onNowPlayingItemDidChange(attributes: any): void { + // if (this.airtunes && this.device) { + // let title = attributes.name ? attributes.name : ''; + // let artist = attributes.artistName ? attributes.artistName : ''; + // let album = attributes.albumName ? attributes.albumName : ''; + // let artworkURL = attributes?.artwork?.url?.replace('{w}', '1024').replace('{h}', '1024') ?? null; + // console.log(this.device.key, title, artist, album); + // this.airtunes.setTrackInfo(this.device.key, title, artist, album); + // if (artworkURL) + // this.uploadImageAirplay(artworkURL) + // } + // } + + /** + * Runs on playback State Change + * @param attributes Music Attributes (attributes.status = current state) + */ + onPlaybackStateDidChange(attributes: any): void { + if (this.airtunes && this.device) { + let title = attributes?.name ?? ''; + let artist = attributes?.artistName ?? ''; + let album = attributes?.albumName ?? ''; + let artworkURL = attributes?.artwork?.url ?? null; + console.log(this.device.key, title, artist, album); + this.airtunes.setTrackInfo(this.device.key, title, artist, album); + if (artworkURL != null){} + this.uploadImageAirplay(artworkURL.replace('{w}', '1024').replace('{h}', '1024')) + } + } + +} \ No newline at end of file diff --git a/src/renderer/views/components/castmenu.ejs b/src/renderer/views/components/castmenu.ejs index 2cf42e54..63b68d5b 100644 --- a/src/renderer/views/components/castmenu.ejs +++ b/src/renderer/views/components/castmenu.ejs @@ -33,11 +33,27 @@ -
{{$root.getLz('action.cast.airplay')}}
-
+
{{$root.getLz('action.cast.airplay')}}
+
- {{$root.getLz('action.cast.airplay.underdevelopment')}} + {{$root.cfg.advanced.ffmpegLocation != "" ? 'Homepods only for now!' : 'Please add FFmpeg location in Settings -> Advanced'}} + +
@@ -84,8 +100,10 @@ let self = this; this.scanning = true; ipcRenderer.send('getChromeCastDevices', ''); + ipcRenderer.send("getAirplayDevice","") setTimeout(() => { self.devices.cast = ipcRenderer.sendSync("getKnownCastDevices"); + self.devices.airplay = ipcRenderer.sendSync("getKnownAirplayDevices"); self.scanning = false; }, 2000); console.log(this.devices); @@ -96,8 +114,13 @@ this.activeCasts.push(device); ipcRenderer.send('performGCCast', device, "Cider", "Playing ...", "Test build", ''); }, + setAirPlayCast(device) { + this.activeCasts.push(device); + ipcRenderer.send("performAirplayPCM",device.host,device.port,null,"","","","") + }, stopCasting() { CiderAudio.stopAudio(); + ipcRenderer.send('disconnectAirplay', ''); ipcRenderer.send('stopGCast', ''); this.activeCasts = []; // vm.$forceUpdate(); diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs index 1de80810..65f39bfd 100644 --- a/src/renderer/views/pages/settings.ejs +++ b/src/renderer/views/pages/settings.ejs @@ -915,6 +915,17 @@
+
+
+ FFmpeg location
+ Restart needed to work. Required for AirPlay. (For example: C:\ffmpeg-4.4-essentials_build\bin\ffmpeg.exe)
+ You can look at the internet on how to install it. +
+
+ +
+
+
{{$root.getLz('settings.option.visual.plugin.github.explore')}} From 6176c286acf4b12c7a1755245c237e1475d7578d Mon Sep 17 00:00:00 2001 From: vapormusic Date: Sat, 23 Apr 2022 01:43:00 +0700 Subject: [PATCH 18/27] test1 --- winget.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winget.json b/winget.json index 4468a361..5b62c059 100644 --- a/winget.json +++ b/winget.json @@ -1,7 +1,7 @@ { - "electronVersion": "16.0.07", + "electronVersion": "18.0.3", "electronDownload": { - "version": "16.0.7+wvcus", + "version": "18.0.3+wvcus", "mirror": "https://github.com/castlabs/electron-releases/releases/download/v" }, "appId": "cider", From b28c2713e0d649e970d54e66f0a2419da2e50a0c Mon Sep 17 00:00:00 2001 From: vapormusic Date: Sat, 23 Apr 2022 01:58:07 +0700 Subject: [PATCH 19/27] cry --- src/renderer/views/components/castmenu.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/views/components/castmenu.ejs b/src/renderer/views/components/castmenu.ejs index 63b68d5b..39fcaa43 100644 --- a/src/renderer/views/components/castmenu.ejs +++ b/src/renderer/views/components/castmenu.ejs @@ -37,7 +37,7 @@
- {{$root.cfg.advanced.ffmpegLocation != "" ? 'Homepods only for now!' : 'Please add FFmpeg location in Settings -> Advanced'}} + {{$root.cfg.advanced.ffmpegLocation != "" ? 'Homepods only for now! (NO PASSWORD PLEASE!)' : 'Please add FFmpeg location in Settings -> Advanced'}}