@@ -77,7 +77,7 @@ function setupMPRIS() {
7777
7878 instance . canRaise = true ;
7979 instance . canQuit = false ;
80- instance . canSetFullscreen = true ;
80+ instance . canUsePlayerControls = true ;
8181 instance . supportedUriSchemes = [ 'http' , 'https' ] ;
8282 instance . desktopEntry = 'youtube-music' ;
8383 return instance ;
@@ -93,6 +93,7 @@ function registerMPRIS(win: BrowserWindow) {
9393 shuffle,
9494 switchRepeat,
9595 setFullscreen,
96+ requestShuffleInformation,
9697 requestFullscreenInformation,
9798 requestQueueInformation,
9899 } = songControls ;
@@ -126,8 +127,10 @@ function registerMPRIS(win: BrowserWindow) {
126127 win . webContents . send ( 'ytmd:setup-time-changed-listener' , 'mpris' ) ;
127128 win . webContents . send ( 'ytmd:setup-repeat-changed-listener' , 'mpris' ) ;
128129 win . webContents . send ( 'ytmd:setup-volume-changed-listener' , 'mpris' ) ;
130+ win . webContents . send ( 'ytmd:setup-shuffle-changed-listener' , 'mpris' ) ;
129131 win . webContents . send ( 'ytmd:setup-fullscreen-changed-listener' , 'mpris' ) ;
130132 win . webContents . send ( 'ytmd:setup-autoplay-changed-listener' , 'mpris' ) ;
133+ requestShuffleInformation ( ) ;
131134 requestFullscreenInformation ( ) ;
132135 requestQueueInformation ( ) ;
133136 } ) ;
@@ -156,8 +159,16 @@ function registerMPRIS(win: BrowserWindow) {
156159 requestQueueInformation ( ) ;
157160 } ) ;
158161
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+
159170 ipcMain . on ( 'ytmd:fullscreen-changed' , ( _ , changedTo : boolean ) => {
160- if ( player . fullscreen === undefined || ! player . canSetFullscreen ) {
171+ if ( player . fullscreen === undefined || ! player . canUsePlayerControls ) {
161172 return ;
162173 }
163174
@@ -168,7 +179,7 @@ function registerMPRIS(win: BrowserWindow) {
168179 ipcMain . on (
169180 'ytmd:set-fullscreen' ,
170181 ( _ , isFullscreen : boolean | undefined ) => {
171- if ( ! player . canSetFullscreen || isFullscreen === undefined ) {
182+ if ( ! player . canUsePlayerControls || isFullscreen === undefined ) {
172183 return ;
173184 }
174185
@@ -179,7 +190,7 @@ function registerMPRIS(win: BrowserWindow) {
179190 ipcMain . on (
180191 'ytmd:fullscreen-changed-supported' ,
181192 ( _ , isFullscreenSupported : boolean ) => {
182- player . canSetFullscreen = isFullscreenSupported ;
193+ player . canUsePlayerControls = isFullscreenSupported ;
183194 } ,
184195 ) ;
185196 ipcMain . on ( 'ytmd:autoplay-changed' , ( _ ) => {
@@ -272,6 +283,12 @@ function registerMPRIS(win: BrowserWindow) {
272283 player . on ( 'position' , seekTo ) ;
273284
274285 player . on ( 'shuffle' , ( enableShuffle ) => {
286+ if ( ! player . canUsePlayerControls || enableShuffle === undefined ) {
287+ return ;
288+ }
289+
290+ player . shuffle = enableShuffle ;
291+
275292 if ( enableShuffle ) {
276293 shuffle ( ) ;
277294 requestQueueInformation ( ) ;
0 commit comments