fix autoplay of inline videos in ios

This commit is contained in:
Hakim El Hattab 2018-03-05 14:59:32 +01:00
parent 5848a432d9
commit 0282413b69
1 changed files with 7 additions and 0 deletions

View File

@ -3498,9 +3498,16 @@
if( autoplay && typeof el.play === 'function' ) {
// If the media is ready, start playback
if( el.readyState > 1 ) {
startEmbeddedMedia( { target: el } );
}
// Mobile devices never fire a loaded event so instead
// of waiting, we initiate playback
else if( isMobileDevice ) {
el.play();
}
// If the media isn't loaded, wait before playing
else {
el.removeEventListener( 'loadeddata', startEmbeddedMedia ); // remove first to avoid dupes
el.addEventListener( 'loadeddata', startEmbeddedMedia );