mirror of
https://github.com/videojs/video.js.git
synced 2025-07-07 01:07:13 +02:00
fix: disable HLS hack on Firefox for Android (#3586)
* Disable HLS hack on Firefox for Android * Fix canPlayType patching tests * Add test to ensure that canPlayType is not patched in Firefox for Android * Fix assertion message in Firefox for Android test
This commit is contained in:
@ -1321,7 +1321,7 @@ const mp4RE = /^video\/mp4/i;
|
|||||||
|
|
||||||
Html5.patchCanPlayType = function() {
|
Html5.patchCanPlayType = function() {
|
||||||
// Android 4.0 and above can play HLS to some extent but it reports being unable to do so
|
// Android 4.0 and above can play HLS to some extent but it reports being unable to do so
|
||||||
if (browser.ANDROID_VERSION >= 4.0) {
|
if (browser.ANDROID_VERSION >= 4.0 && !browser.IS_FIREFOX) {
|
||||||
if (!canPlayType) {
|
if (!canPlayType) {
|
||||||
canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
|
canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
|
||||||
}
|
}
|
||||||
|
@ -110,10 +110,12 @@ QUnit.test('patchCanPlayType patches canplaytype with our function, conditionall
|
|||||||
Html5.unpatchCanPlayType();
|
Html5.unpatchCanPlayType();
|
||||||
|
|
||||||
const oldAV = browser.ANDROID_VERSION;
|
const oldAV = browser.ANDROID_VERSION;
|
||||||
|
const oldIsFirefox = browser.IS_FIREFOX;
|
||||||
const video = document.createElement('video');
|
const video = document.createElement('video');
|
||||||
const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
|
const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
|
||||||
|
|
||||||
browser.ANDROID_VERSION = 4.0;
|
browser.ANDROID_VERSION = 4.0;
|
||||||
|
browser.IS_FIREFOX = false;
|
||||||
Html5.patchCanPlayType();
|
Html5.patchCanPlayType();
|
||||||
|
|
||||||
assert.notStrictEqual(video.canPlayType,
|
assert.notStrictEqual(video.canPlayType,
|
||||||
@ -131,14 +133,39 @@ QUnit.test('patchCanPlayType patches canplaytype with our function, conditionall
|
|||||||
'patched canPlayType and function returned from unpatch are equal');
|
'patched canPlayType and function returned from unpatch are equal');
|
||||||
|
|
||||||
browser.ANDROID_VERSION = oldAV;
|
browser.ANDROID_VERSION = oldAV;
|
||||||
|
browser.IS_FIREFOX = oldIsFirefox;
|
||||||
|
Html5.unpatchCanPlayType();
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test('patchCanPlayType doesn\'t patch canplaytype with our function in Firefox for Android', function(assert) {
|
||||||
|
// the patch runs automatically so we need to first unpatch
|
||||||
|
Html5.unpatchCanPlayType();
|
||||||
|
|
||||||
|
const oldAV = browser.ANDROID_VERSION;
|
||||||
|
const oldIsFirefox = browser.IS_FIREFOX;
|
||||||
|
const video = document.createElement('video');
|
||||||
|
const canPlayType = Html5.TEST_VID.constructor.prototype.canPlayType;
|
||||||
|
|
||||||
|
browser.ANDROID_VERSION = 4.0;
|
||||||
|
browser.IS_FIREFOX = true;
|
||||||
|
Html5.patchCanPlayType();
|
||||||
|
|
||||||
|
assert.strictEqual(video.canPlayType,
|
||||||
|
canPlayType,
|
||||||
|
'original canPlayType and patched canPlayType should be equal');
|
||||||
|
|
||||||
|
browser.ANDROID_VERSION = oldAV;
|
||||||
|
browser.IS_FIREFOX = oldIsFirefox;
|
||||||
Html5.unpatchCanPlayType();
|
Html5.unpatchCanPlayType();
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should return maybe for HLS urls on Android 4.0 or above', function(assert) {
|
QUnit.test('should return maybe for HLS urls on Android 4.0 or above', function(assert) {
|
||||||
const oldAV = browser.ANDROID_VERSION;
|
const oldAV = browser.ANDROID_VERSION;
|
||||||
|
const oldIsFirefox = browser.IS_FIREFOX;
|
||||||
const video = document.createElement('video');
|
const video = document.createElement('video');
|
||||||
|
|
||||||
browser.ANDROID_VERSION = 4.0;
|
browser.ANDROID_VERSION = 4.0;
|
||||||
|
browser.IS_FIREFOX = false;
|
||||||
Html5.patchCanPlayType();
|
Html5.patchCanPlayType();
|
||||||
|
|
||||||
assert.strictEqual(video.canPlayType('application/x-mpegurl'),
|
assert.strictEqual(video.canPlayType('application/x-mpegurl'),
|
||||||
@ -157,6 +184,7 @@ QUnit.test('should return maybe for HLS urls on Android 4.0 or above', function(
|
|||||||
'maybe for vnd.apple.mpegurl');
|
'maybe for vnd.apple.mpegurl');
|
||||||
|
|
||||||
browser.ANDROID_VERSION = oldAV;
|
browser.ANDROID_VERSION = oldAV;
|
||||||
|
browser.IS_FIREFOX = oldIsFirefox;
|
||||||
Html5.unpatchCanPlayType();
|
Html5.unpatchCanPlayType();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user