@@ -102,18 +102,21 @@ function registerMPRIS(win: BrowserWindow) {
102102 return videoId . replace ( / - / g, '_MINUS_' ) ;
103103 } ;
104104
105+ const player = setupMPRIS ( ) ;
106+
105107 const seekTo = ( event : Position ) => {
106108 if (
107109 currentSongInfo ?. videoId &&
108110 event . trackId . endsWith ( correctId ( currentSongInfo . videoId ) )
109111 ) {
110112 win . webContents . send ( 'ytmd:seek-to' , microToSec ( event . position ?? 0 ) ) ;
113+ player . setPosition ( event . position ?? 0 ) ;
111114 }
112115 } ;
113- const seekBy = ( offset : number ) =>
116+ const seekBy = ( offset : number ) => {
114117 win . webContents . send ( 'ytmd:seek-by' , microToSec ( offset ) ) ;
115-
116- const player = setupMPRIS ( ) ;
118+ player . setPosition ( player . getPosition ( ) + offset ) ;
119+ } ;
117120
118121 ipcMain . on ( 'ytmd:player-api-loaded' , ( ) => {
119122 win . webContents . send ( 'ytmd:setup-seeked-listener' , 'mpris' ) ;
@@ -126,7 +129,10 @@ function registerMPRIS(win: BrowserWindow) {
126129 requestQueueInformation ( ) ;
127130 } ) ;
128131
129- ipcMain . on ( 'ytmd:seeked' , ( _ , t : number ) => player . seeked ( secToMicro ( t ) ) ) ;
132+ ipcMain . on ( 'ytmd:seeked' , ( _ , t : number ) => {
133+ player . setPosition ( secToMicro ( t ) ) ;
134+ player . seeked ( secToMicro ( t ) ) ;
135+ } ) ;
130136
131137 ipcMain . on ( 'ytmd:time-changed' , ( _ , t : number ) => {
132138 player . setPosition ( secToMicro ( t ) ) ;
0 commit comments