@@ -102,18 +102,21 @@ function registerMPRIS(win: BrowserWindow) {
102
102
return videoId . replace ( / - / g, '_MINUS_' ) ;
103
103
} ;
104
104
105
+ const player = setupMPRIS ( ) ;
106
+
105
107
const seekTo = ( event : Position ) => {
106
108
if (
107
109
currentSongInfo ?. videoId &&
108
110
event . trackId . endsWith ( correctId ( currentSongInfo . videoId ) )
109
111
) {
110
112
win . webContents . send ( 'ytmd:seek-to' , microToSec ( event . position ?? 0 ) ) ;
113
+ player . setPosition ( event . position ?? 0 ) ;
111
114
}
112
115
} ;
113
- const seekBy = ( offset : number ) =>
116
+ const seekBy = ( offset : number ) => {
114
117
win . webContents . send ( 'ytmd:seek-by' , microToSec ( offset ) ) ;
115
-
116
- const player = setupMPRIS ( ) ;
118
+ player . setPosition ( player . getPosition ( ) + offset ) ;
119
+ } ;
117
120
118
121
ipcMain . on ( 'ytmd:player-api-loaded' , ( ) => {
119
122
win . webContents . send ( 'ytmd:setup-seeked-listener' , 'mpris' ) ;
@@ -126,7 +129,10 @@ function registerMPRIS(win: BrowserWindow) {
126
129
requestQueueInformation ( ) ;
127
130
} ) ;
128
131
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
+ } ) ;
130
136
131
137
ipcMain . on ( 'ytmd:time-changed' , ( _ , t : number ) => {
132
138
player . setPosition ( secToMicro ( t ) ) ;
0 commit comments