Add setting to disable OS media player APIs

This commit is contained in:
Drew Weymouth
2025-05-26 17:17:00 -07:00
parent 1390c41657
commit af1ae4641e
5 changed files with 32 additions and 16 deletions
+13 -9
View File
@@ -191,14 +191,16 @@ func StartupApp(appName, displayAppName, appVersion, appVersionTag, latestReleas
}
// OS media center integrations
// Linux MPRIS
a.setupMPRIS(displayAppName)
// MacOS MPNowPlayingInfoCenter
InitMPMediaHandler(a.PlaybackManager, func(id string) (string, error) {
a.ImageManager.GetCoverThumbnail(id) // ensure image is cached locally
return a.ImageManager.GetCoverArtUrl(id)
})
// Windows SMTC is initialized from main once we have a window HWND.
if a.Config.Application.EnableOSMediaPlayerAPIs {
// Linux MPRIS
a.setupMPRIS(displayAppName)
// MacOS MPNowPlayingInfoCenter
InitMPMediaHandler(a.PlaybackManager, func(id string) (string, error) {
a.ImageManager.GetCoverThumbnail(id) // ensure image is cached locally
return a.ImageManager.GetCoverArtUrl(id)
})
// Windows SMTC is initialized from main once we have a window HWND.
}
a.startConfigWriter(a.bgrndCtx)
@@ -458,7 +460,9 @@ func (a *App) Shutdown() {
if a.ipcServer != nil {
a.ipcServer.Shutdown(a.bgrndCtx)
}
a.MPRISHandler.Shutdown()
if a.MPRISHandler != nil {
a.MPRISHandler.Shutdown()
}
if a.WinSMTC != nil {
a.WinSMTC.Shutdown()
}
+2
View File
@@ -55,6 +55,7 @@ type AppConfig struct {
DisableDPIDetection bool
EnableAutoUpdateChecker bool
RequestTimeoutSeconds int
EnableOSMediaPlayerAPIs bool
FontNormalTTF string
FontBoldTTF string
@@ -192,6 +193,7 @@ func DefaultConfig(appVersionTag string) *Config {
Language: "auto",
EnableAutoUpdateChecker: true,
RequestTimeoutSeconds: 15,
EnableOSMediaPlayerAPIs: true,
},
AlbumPage: AlbumPageConfig{
TracklistColumns: []string{"Artist", "Time", "Plays", "Favorite", "Rating"},
+9 -7
View File
@@ -91,13 +91,15 @@ func main() {
mainWindow.Controller.DoConnectToServerWorkflow(defaultServer)
}
mainWindow.Window.(driver.NativeWindow).RunNative(func(ctx any) {
// intialize Windows SMTC
if runtime.GOOS == "windows" {
hwnd := ctx.(driver.WindowsWindowContext).HWND
myApp.SetupWindowsSMTC(hwnd)
}
})
if myApp.Config.Application.EnableOSMediaPlayerAPIs {
mainWindow.Window.(driver.NativeWindow).RunNative(func(ctx any) {
// intialize Windows SMTC
if runtime.GOOS == "windows" {
hwnd := ctx.(driver.WindowsWindowContext).HWND
myApp.SetupWindowsSMTC(hwnd)
}
})
}
})
fyneApp.Lifecycle().SetOnEnteredForeground(windowStartupTasks)
+1
View File
@@ -76,6 +76,7 @@
"Edit Playlist": "Edit Playlist",
"Edit server": "Edit server",
"Enable LrcLib lyrics fetcher": "Enable LrcLib lyrics fetcher",
"Enable OS media player integration": "Enable OS media player integration",
"Enable system tray": "Enable system tray",
"Enabled": "Enabled",
"Enter": "Enter",
+7
View File
@@ -562,11 +562,18 @@ func (s *SettingsDialog) createAdvancedTab() *container.TabItem {
widget.NewLabel("MB"),
)
osMediaAPIs := widget.NewCheck(lang.L("Enable OS media player integration"), func(b bool) {
s.config.Application.EnableOSMediaPlayerAPIs = b
s.setRestartRequired()
})
osMediaAPIs.Checked = s.config.Application.EnableOSMediaPlayerAPIs
return container.NewTabItem(lang.L("Advanced"), container.NewVBox(
multi,
sslSkip,
update,
lrclib,
osMediaAPIs,
imgCacheCfg,
))
}