add Windows taskbar control buttons (TODO: icons)
This commit is contained in:
committed by
Drew Weymouth
parent
21edd38f38
commit
aedaa32de4
+25
-11
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/dweymouth/supersonic/backend/player"
|
||||
"github.com/dweymouth/supersonic/backend/player/mpv"
|
||||
"github.com/dweymouth/supersonic/backend/util"
|
||||
"github.com/dweymouth/supersonic/backend/windows"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/20after4/configdir"
|
||||
@@ -49,7 +50,7 @@ type App struct {
|
||||
LocalPlayer *mpv.Player
|
||||
UpdateChecker UpdateChecker
|
||||
MPRISHandler *MPRISHandler
|
||||
WinSMTC *SMTC
|
||||
WinSMTC *windows.SMTC
|
||||
ipcServer ipc.IPCServer
|
||||
LrcLibFetcher *LrcLibFetcher
|
||||
|
||||
@@ -378,7 +379,7 @@ func (a *App) setupMPRIS(mprisAppName string) {
|
||||
}
|
||||
|
||||
func (a *App) SetupWindowsSMTC(hwnd uintptr) {
|
||||
smtc, err := InitSMTCForWindow(hwnd)
|
||||
smtc, err := windows.InitSMTCForWindow(hwnd)
|
||||
if err != nil {
|
||||
log.Printf("error initializing SMTC: %d", err)
|
||||
return
|
||||
@@ -386,17 +387,17 @@ func (a *App) SetupWindowsSMTC(hwnd uintptr) {
|
||||
a.WinSMTC = smtc
|
||||
smtc.UpdateMetadata(a.displayAppName, "")
|
||||
|
||||
smtc.OnButtonPressed(func(btn SMTCButton) {
|
||||
smtc.OnButtonPressed(func(btn windows.SMTCButton) {
|
||||
switch btn {
|
||||
case SMTCButtonPlay:
|
||||
case windows.SMTCButtonPlay:
|
||||
a.PlaybackManager.Continue()
|
||||
case SMTCButtonPause:
|
||||
case windows.SMTCButtonPause:
|
||||
a.PlaybackManager.Pause()
|
||||
case SMTCButtonNext:
|
||||
case windows.SMTCButtonNext:
|
||||
a.PlaybackManager.SeekNext()
|
||||
case SMTCButtonPrevious:
|
||||
case windows.SMTCButtonPrevious:
|
||||
a.PlaybackManager.SeekBackOrPrevious()
|
||||
case SMTCButtonStop:
|
||||
case windows.SMTCButtonStop:
|
||||
a.PlaybackManager.Stop()
|
||||
}
|
||||
})
|
||||
@@ -425,15 +426,28 @@ func (a *App) SetupWindowsSMTC(hwnd uintptr) {
|
||||
})
|
||||
a.PlaybackManager.OnPlaying(func() {
|
||||
smtc.SetEnabled(true)
|
||||
smtc.UpdatePlaybackState(SMTCPlaybackStatePlaying)
|
||||
smtc.UpdatePlaybackState(windows.SMTCPlaybackStatePlaying)
|
||||
})
|
||||
a.PlaybackManager.OnPaused(func() {
|
||||
smtc.SetEnabled(true)
|
||||
smtc.UpdatePlaybackState(SMTCPlaybackStatePaused)
|
||||
smtc.UpdatePlaybackState(windows.SMTCPlaybackStatePaused)
|
||||
})
|
||||
a.PlaybackManager.OnStopped(func() {
|
||||
smtc.SetEnabled(false)
|
||||
smtc.UpdatePlaybackState(SMTCPlaybackStateStopped)
|
||||
smtc.UpdatePlaybackState(windows.SMTCPlaybackStateStopped)
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) SetupWindowsTaskbarButtons(hwnd uintptr) {
|
||||
windows.InitializeTaskbarButtons(hwnd, func(btn windows.TaskbarButton) {
|
||||
switch btn {
|
||||
case windows.TaskbarButtonPrevious:
|
||||
a.PlaybackManager.SeekBackOrPrevious()
|
||||
case windows.TaskbarButtonPlayPause:
|
||||
a.PlaybackManager.PlayPause()
|
||||
case windows.TaskbarButtonNext:
|
||||
a.PlaybackManager.SeekNext()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user