/** * @author Richard Davey * @copyright 2019 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * Determines the video support of the browser running this Phaser Game instance. * These values are read-only and populated during the boot sequence of the game. * They are then referenced by internal game systems and are available for you to access * via `this.sys.game.device.video` from within any Scene. * * @typedef {object} Phaser.Device.Video * @since 3.0.0 * * @property {boolean} h264Video - Can this device play h264 mp4 video files? * @property {boolean} hlsVideo - Can this device play hls video files? * @property {boolean} mp4Video - Can this device play h264 mp4 video files? * @property {boolean} oggVideo - Can this device play ogg video files? * @property {boolean} vp9Video - Can this device play vp9 video files? * @property {boolean} webmVideo - Can this device play webm video files? */ var Video = { h264Video: false, hlsVideo: false, mp4Video: false, oggVideo: false, vp9Video: false, webmVideo: false }; function init () { var videoElement = document.createElement('video'); var result = !!videoElement.canPlayType; try { if (result) { if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) { Video.oggVideo = true; } if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) { // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 Video.h264Video = true; Video.mp4Video = true; } if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) { Video.webmVideo = true; } if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) { Video.vp9Video = true; } if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) { Video.hlsVideo = true; } } } catch (e) { // Nothing to do } return Video; } module.exports = init();