@@ -20,6 +20,7 @@ let customThumbImg = null;
20
20
let customChapterText = null ;
21
21
22
22
let osdPositionSlider = null ;
23
+ let osdOriginalBubbleHtml = null ;
23
24
let osdGetBubbleHtml = null ;
24
25
let osdGetBubbleHtmlLock = false ;
25
26
@@ -114,6 +115,8 @@ function loadVideoView() {
114
115
osdPositionSlider = slider ;
115
116
debug ( `Found OSD slider: ${ osdPositionSlider } ` ) ;
116
117
118
+ osdOriginalBubbleHtml = osdPositionSlider . getBubbleHtml ;
119
+
117
120
Object . defineProperty ( osdPositionSlider , 'getBubbleHtml' , {
118
121
get ( ) { return osdGetBubbleHtml } ,
119
122
set ( value ) { if ( ! osdGetBubbleHtmlLock ) osdGetBubbleHtml = value ; } ,
@@ -184,6 +187,7 @@ function unloadVideoView() {
184
187
customChapterText = null ;
185
188
186
189
osdPositionSlider = null ;
190
+ osdOriginalBubbleHtml = null ;
187
191
osdGetBubbleHtml = null ;
188
192
osdGetBubbleHtmlLock = false ;
189
193
// Clear old values
@@ -203,6 +207,8 @@ window.fetch = async (...args) => {
203
207
let urlParts = url . pathname . split ( '/' ) ;
204
208
let isPlaybackInfo = urlParts . pop ( ) == 'PlaybackInfo' ;
205
209
210
+ const response = await originalFetch ( resource , config ) ;
211
+
206
212
if ( isPlaybackInfo ) {
207
213
mediaSourceId = new URLSearchParams ( url . search ) . get ( 'MediaSourceId' ) ;
208
214
mediaSourceId = mediaSourceId ?? urlParts . pop ( ) ;
@@ -212,16 +218,16 @@ window.fetch = async (...args) => {
212
218
let auth = config . headers [ 'X-Emby-Authorization' ] ;
213
219
embyAuthValue = auth ?? '' ;
214
220
debug ( `Using Emby auth value: ${ embyAuthValue } ` ) ;
215
- }
216
221
217
- const response = await originalFetch ( resource , config ) ;
218
-
219
- if ( isPlaybackInfo ) {
220
222
response . clone ( ) . json ( ) . then ( ( data ) => {
221
223
for ( const source of data . MediaSources ) {
222
224
if ( source . Id == mediaSourceId ) {
223
225
mediaRuntimeTicks = source . RunTimeTicks ;
224
226
debug ( `Found media runtime of ${ mediaRuntimeTicks } ticks` ) ;
227
+
228
+ debug ( `Attempting to change trickplay data to source ${ mediaSourceId } ` ) ;
229
+ changeCurrentMedia ( ) ;
230
+
225
231
break ;
226
232
} else {
227
233
debug ( `Runtime -- found media source ID ${ source . Id } but main source is ${ mediaSourceId } ` ) ;
@@ -233,6 +239,23 @@ window.fetch = async (...args) => {
233
239
return response ;
234
240
} ;
235
241
242
+ function changeCurrentMedia ( ) {
243
+ // Reset trickplay-related variables
244
+ hasFailed = false ;
245
+ trickplayManifest = null ;
246
+ trickplayData = null ;
247
+ currentTrickplayFrame = null ;
248
+
249
+ // Set bubble html back to default
250
+ if ( osdOriginalBubbleHtml ) osdGetBubbleHtml = osdOriginalBubbleHtml ;
251
+ osdGetBubbleHtmlLock = false ;
252
+
253
+ // Main execution will first by triggered by the load video view method, but later (e.g. in the case of TV series)
254
+ // will be triggered by the playback request interception
255
+ if ( ! hasFailed && ! trickplayData && mediaSourceId && mediaRuntimeTicks && embyAuthValue
256
+ && osdPositionSlider && hiddenSliderBubble && customSliderBubble ) mainScriptExecution ( ) ;
257
+ }
258
+
236
259
/*
237
260
* Indexed UInt8Array
238
261
*/
0 commit comments