This commit is contained in:
hakimel 2021-11-24 11:07:11 +01:00
parent ec32d44085
commit c5d549810e
4 changed files with 25 additions and 5 deletions

2
dist/reveal.esm.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,4 @@
import { HORIZONTAL_SLIDES_SELECTOR, VERTICAL_SLIDES_SELECTOR } from '../utils/constants.js' import { extend, queryAll, closest, getMimeTypeFromFile } from '../utils/util.js'
import { extend, queryAll, closest } from '../utils/util.js'
import { isMobile } from '../utils/device.js' import { isMobile } from '../utils/device.js'
import fitty from 'fitty'; import fitty from 'fitty';
@ -137,7 +136,13 @@ export default class SlideContent {
// Support comma separated lists of video sources // Support comma separated lists of video sources
backgroundVideo.split( ',' ).forEach( source => { backgroundVideo.split( ',' ).forEach( source => {
video.innerHTML += '<source src="'+ source +'" type="video/' + source.split(".").pop() + '">'; let type = getMimeTypeFromFile( source );
if( type ) {
video.innerHTML += `<source src="${source}" type="${type}">`;
}
else {
video.innerHTML += `<source src="${source}">`;
}
} ); } );
backgroundContent.appendChild( video ); backgroundContent.appendChild( video );

View File

@ -280,3 +280,18 @@ export const getRemainingHeight = ( element, height = 0 ) => {
return height; return height;
} }
const fileExtensionToMimeMap = {
'mp4': 'video/mp4',
'm4a': 'video/mp4',
'ogv': 'video/ogg',
'mpeg': 'video/mpeg',
'webm': 'video/webm'
}
/**
* Guess the MIME type for common file formats.
*/
export const getMimeTypeFromFile = ( filename='' ) => {
return fileExtensionToMimeMap[filename.split('.').pop()]
}