Skip to content

Instantly share code, notes, and snippets.

@bvibber
Created May 9, 2022 20:30
Show Gist options
  • Save bvibber/db7b19b605cb965c6f3ffe6c3fe93752 to your computer and use it in GitHub Desktop.
Save bvibber/db7b19b605cb965c6f3ffe6c3fe93752 to your computer and use it in GitHub Desktop.
diff --git a/resources/ext.tmh.OgvJsSupport.js b/resources/ext.tmh.OgvJsSupport.js
index 3ee84110..827ba16d 100644
--- a/resources/ext.tmh.OgvJsSupport.js
+++ b/resources/ext.tmh.OgvJsSupport.js
@@ -86,21 +86,28 @@
* @return {boolean}
*/
isMediaNativelySupported: function ( mediaElement ) {
- var mediaType;
var supportedNatively = false;
var sourcesList = mediaElement.querySelectorAll( 'source' );
// IE11: NodeList.forEach
Array.prototype.forEach.call( sourcesList, function ( source ) {
- mediaType = source.getAttribute( 'type' );
+ var mediaType = source.getAttribute( 'type' );
+ var base = (mediaType.split( ';' ))[0];
+
+ console.log(mediaType, base, mediaElement.canPlayType(mediaType),mediaElement.canPlayType(base),MediaSource.isTypeSupported(mediaType));
if (
mediaElement.canPlayType( mediaType ) || (
// Safari 12 workaround, where safari incorrectly reports not to support opus on webm files
typeof MediaSource !== 'undefined' && MediaSource.isTypeSupported( mediaType )
+ // But beware on iPadOS, where <video> doesn't support WebM sources directly,
+ // so check for the base type, which it *does* claim support for
+ && mediaElement.canPlayType( base )
)
) {
+ console.log('is native');
supportedNatively = true;
}
} );
+ console.log('is not native');
return supportedNatively;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment