diff --git a/js/mediaLibrariesOverrides.js b/js/mediaLibrariesOverrides.js index d9cdef2..56ee0fc 100644 --- a/js/mediaLibrariesOverrides.js +++ b/js/mediaLibrariesOverrides.js @@ -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) */