@@ -77,7 +77,7 @@ function setupMPRIS() {
77
77
78
78
instance . canRaise = true ;
79
79
instance . canQuit = false ;
80
- instance . canSetFullscreen = true ;
80
+ instance . canUsePlayerControls = true ;
81
81
instance . supportedUriSchemes = [ 'http' , 'https' ] ;
82
82
instance . desktopEntry = 'youtube-music' ;
83
83
return instance ;
@@ -93,6 +93,7 @@ function registerMPRIS(win: BrowserWindow) {
93
93
shuffle,
94
94
switchRepeat,
95
95
setFullscreen,
96
+ requestShuffleInformation,
96
97
requestFullscreenInformation,
97
98
requestQueueInformation,
98
99
} = songControls ;
@@ -126,8 +127,10 @@ function registerMPRIS(win: BrowserWindow) {
126
127
win . webContents . send ( 'ytmd:setup-time-changed-listener' , 'mpris' ) ;
127
128
win . webContents . send ( 'ytmd:setup-repeat-changed-listener' , 'mpris' ) ;
128
129
win . webContents . send ( 'ytmd:setup-volume-changed-listener' , 'mpris' ) ;
130
+ win . webContents . send ( 'ytmd:setup-shuffle-changed-listener' , 'mpris' ) ;
129
131
win . webContents . send ( 'ytmd:setup-fullscreen-changed-listener' , 'mpris' ) ;
130
132
win . webContents . send ( 'ytmd:setup-autoplay-changed-listener' , 'mpris' ) ;
133
+ requestShuffleInformation ( ) ;
131
134
requestFullscreenInformation ( ) ;
132
135
requestQueueInformation ( ) ;
133
136
} ) ;
@@ -156,8 +159,16 @@ function registerMPRIS(win: BrowserWindow) {
156
159
requestQueueInformation ( ) ;
157
160
} ) ;
158
161
162
+ ipcMain . on ( 'ytmd:shuffle-changed' , ( _ , shuffleEnabled : boolean ) => {
163
+ if ( player . shuffle === undefined || ! player . canUsePlayerControls ) {
164
+ return ;
165
+ }
166
+
167
+ player . shuffle = shuffleEnabled ?? ! player . shuffle ;
168
+ } ) ;
169
+
159
170
ipcMain . on ( 'ytmd:fullscreen-changed' , ( _ , changedTo : boolean ) => {
160
- if ( player . fullscreen === undefined || ! player . canSetFullscreen ) {
171
+ if ( player . fullscreen === undefined || ! player . canUsePlayerControls ) {
161
172
return ;
162
173
}
163
174
@@ -168,7 +179,7 @@ function registerMPRIS(win: BrowserWindow) {
168
179
ipcMain . on (
169
180
'ytmd:set-fullscreen' ,
170
181
( _ , isFullscreen : boolean | undefined ) => {
171
- if ( ! player . canSetFullscreen || isFullscreen === undefined ) {
182
+ if ( ! player . canUsePlayerControls || isFullscreen === undefined ) {
172
183
return ;
173
184
}
174
185
@@ -179,7 +190,7 @@ function registerMPRIS(win: BrowserWindow) {
179
190
ipcMain . on (
180
191
'ytmd:fullscreen-changed-supported' ,
181
192
( _ , isFullscreenSupported : boolean ) => {
182
- player . canSetFullscreen = isFullscreenSupported ;
193
+ player . canUsePlayerControls = isFullscreenSupported ;
183
194
} ,
184
195
) ;
185
196
ipcMain . on ( 'ytmd:autoplay-changed' , ( _ ) => {
@@ -272,6 +283,12 @@ function registerMPRIS(win: BrowserWindow) {
272
283
player . on ( 'position' , seekTo ) ;
273
284
274
285
player . on ( 'shuffle' , ( enableShuffle ) => {
286
+ if ( ! player . canUsePlayerControls || enableShuffle === undefined ) {
287
+ return ;
288
+ }
289
+
290
+ player . shuffle = enableShuffle ;
291
+
275
292
if ( enableShuffle ) {
276
293
shuffle ( ) ;
277
294
requestQueueInformation ( ) ;
0 commit comments