Skip to content

Commit

Permalink
Fix: Firefox fullscreen api (fixes #239) (#259)
Browse files Browse the repository at this point in the history
* Fix: Firefox fullscren api (fixes #239)

* Changed override style

* Upmerge master

* Reapply original fix for #239

* Check if browser is currently in fullscreen before canceling fullscreen

---------

Co-authored-by: Brad Simpson <[email protected]>
  • Loading branch information
oliverfoster and swashbuck authored Sep 2, 2024
1 parent a9f2bc7 commit 84d50dc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions js/mediaLibrariesOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,35 @@ window.mejs.MediaElementPlayer.prototype.setTrack = function (lang) {

};

/**
* Fix for firefox fullscreen api
* https://github.com/adaptlearning/adapt-contrib-media/issues/239
*/
const mediaFeatures = window.mejs.MediaFeatures;
if (mediaFeatures.hasMozNativeFullScreen) {
Object.assign(mediaFeatures, {
fullScreenEventName: document.exitFullscreen
? 'fullscreenchange'
: 'mozfullscreenchange',
requestFullScreen: el => {
document.exitFullscreen
? el.requestFullscreen()
: el.mozRequestFullScreen();
},
isFullScreen: () => {
return document.exitFullscreen
? Boolean(document.fullscreenElement)
: document.mozFullScreen;
},
cancelFullScreen: el => {
if (!mediaFeatures.isFullScreen()) return;
document.exitFullscreen
? document.exitFullscreen()
: document.mozCancelFullScreen();
}
});
}

/**
* Overwrite mediaelement-and-player enterFullScreen to remove Chrome <17 bug fix (Media issue #255)
*/
Expand Down

0 comments on commit 84d50dc

Please sign in to comment.