Skip to content

Commit a6ab73f

Browse files
committed
HFP-3143 Fix Safari not resizing properly
Safari does not handle the 'canplay' event from video elements, so we must listen for both 'loadedmetadata' and 'canplay' events in h5p-video and make sure we resize after the last event we get here in IV
1 parent f565181 commit a6ab73f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/scripts/interactive-video.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,16 @@ function InteractiveVideo(params, id, contentData) {
282282

283283
// Handle video source loaded events (metadata)
284284
self.video.on('loaded', function () {
285+
// If already loaded, just trigger resize. This is necessary
286+
// because some browsers does not handle certain events from
287+
// video, e.g. Safari only handles the 'loadedmetadata' event,
288+
// while FF handles both 'loadedMetadata' and 'canplay' so we want
289+
// to make sure we resize after the last load event we get.
290+
if (isLoaded) {
291+
self.trigger('resize');
292+
return;
293+
}
294+
285295
isLoaded = true;
286296
// Update IV player UI
287297
self.loaded();

0 commit comments

Comments
 (0)