Skip to content

Commit f69f784

Browse files
committed
Fixed broken bubble html and non-loading trickplay on video change
1 parent fdde34b commit f69f784

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

Diff for: Nick.Plugin.Jellyscrub/Api/trickplay.js

+27-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ let customThumbImg = null;
2020
let customChapterText = null;
2121

2222
let osdPositionSlider = null;
23+
let osdOriginalBubbleHtml = null;
2324
let osdGetBubbleHtml = null;
2425
let osdGetBubbleHtmlLock = false;
2526

@@ -114,6 +115,8 @@ function loadVideoView() {
114115
osdPositionSlider = slider;
115116
debug(`Found OSD slider: ${osdPositionSlider}`);
116117

118+
osdOriginalBubbleHtml = osdPositionSlider.getBubbleHtml;
119+
117120
Object.defineProperty(osdPositionSlider, 'getBubbleHtml', {
118121
get() { return osdGetBubbleHtml },
119122
set(value) { if (!osdGetBubbleHtmlLock) osdGetBubbleHtml = value; },
@@ -184,6 +187,7 @@ function unloadVideoView() {
184187
customChapterText = null;
185188

186189
osdPositionSlider = null;
190+
osdOriginalBubbleHtml = null;
187191
osdGetBubbleHtml = null;
188192
osdGetBubbleHtmlLock = false;
189193
// Clear old values
@@ -203,6 +207,8 @@ window.fetch = async (...args) => {
203207
let urlParts = url.pathname.split('/');
204208
let isPlaybackInfo = urlParts.pop() == 'PlaybackInfo';
205209

210+
const response = await originalFetch(resource, config);
211+
206212
if (isPlaybackInfo) {
207213
mediaSourceId = new URLSearchParams(url.search).get('MediaSourceId');
208214
mediaSourceId = mediaSourceId ?? urlParts.pop();
@@ -212,16 +218,16 @@ window.fetch = async (...args) => {
212218
let auth = config.headers['X-Emby-Authorization'];
213219
embyAuthValue = auth ?? '';
214220
debug(`Using Emby auth value: ${embyAuthValue}`);
215-
}
216221

217-
const response = await originalFetch(resource, config);
218-
219-
if (isPlaybackInfo) {
220222
response.clone().json().then((data) => {
221223
for (const source of data.MediaSources) {
222224
if (source.Id == mediaSourceId) {
223225
mediaRuntimeTicks = source.RunTimeTicks;
224226
debug(`Found media runtime of ${mediaRuntimeTicks} ticks`);
227+
228+
debug(`Attempting to change trickplay data to source ${mediaSourceId}`);
229+
changeCurrentMedia();
230+
225231
break;
226232
} else {
227233
debug(`Runtime -- found media source ID ${source.Id} but main source is ${mediaSourceId}`);
@@ -233,6 +239,23 @@ window.fetch = async (...args) => {
233239
return response;
234240
};
235241

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+
236259
/*
237260
* Indexed UInt8Array
238261
*/

0 commit comments

Comments
 (0)