2014-05-17 00:48:05 +03:00
|
|
|
var player, tech, el;
|
|
|
|
|
|
|
|
module('HTML5', {
|
|
|
|
'setup': function() {
|
|
|
|
|
|
|
|
el = document.createElement('div');
|
|
|
|
el.innerHTML = '<div />';
|
|
|
|
|
|
|
|
player = {
|
|
|
|
id: function(){ return 'id'; },
|
|
|
|
el: function(){ return el; },
|
|
|
|
options_: {},
|
|
|
|
options: function(){ return {}; },
|
2014-08-14 02:44:36 +03:00
|
|
|
bufferedPercent: function() { return 0; },
|
2014-05-17 00:48:05 +03:00
|
|
|
controls: function(){ return false; },
|
|
|
|
usingNativeControls: function(){ return false; },
|
|
|
|
on: function(){ return this; },
|
|
|
|
off: function() { return this; },
|
2014-08-14 02:44:36 +03:00
|
|
|
ready: function(){},
|
|
|
|
trigger: function(){}
|
2014-05-17 00:48:05 +03:00
|
|
|
};
|
|
|
|
tech = new vjs.Html5(player, {});
|
|
|
|
},
|
|
|
|
'teardown': function() {
|
|
|
|
tech.dispose();
|
|
|
|
el = null;
|
|
|
|
player = null;
|
|
|
|
tech = null;
|
|
|
|
}
|
|
|
|
});
|
2013-03-02 01:11:20 +03:00
|
|
|
|
|
|
|
test('should detect whether the volume can be changed', function(){
|
2013-03-05 21:38:47 +03:00
|
|
|
var testVid, ConstVolumeVideo;
|
2013-03-06 02:07:35 +03:00
|
|
|
if (!{}['__defineSetter__']) {
|
|
|
|
ok(true, 'your browser does not support this test, skipping it');
|
|
|
|
return;
|
|
|
|
}
|
2013-03-05 21:38:47 +03:00
|
|
|
testVid = vjs.TEST_VID;
|
|
|
|
ConstVolumeVideo = function(){
|
|
|
|
this.volume = 1;
|
|
|
|
this.__defineSetter__('volume', function(){});
|
|
|
|
};
|
2013-03-02 01:11:20 +03:00
|
|
|
vjs.TEST_VID = new ConstVolumeVideo();
|
|
|
|
|
|
|
|
ok(!vjs.Html5.canControlVolume());
|
|
|
|
vjs.TEST_VID = testVid;
|
|
|
|
});
|
2013-03-08 04:57:52 +03:00
|
|
|
|
|
|
|
test('should re-link the player if the tech is moved', function(){
|
2013-04-09 23:18:55 +03:00
|
|
|
vjs.Html5.movingMediaElementInDOM = false;
|
2013-03-08 04:57:52 +03:00
|
|
|
tech.createEl();
|
|
|
|
|
2013-03-08 18:13:01 +03:00
|
|
|
strictEqual(player, tech.el()['player']);
|
2013-08-10 00:29:22 +03:00
|
|
|
});
|
2014-03-18 03:47:47 +03:00
|
|
|
|
2014-05-17 00:48:05 +03:00
|
|
|
test('test playbackRate', function() {
|
|
|
|
var playbackRate;
|
|
|
|
|
2014-09-03 03:38:11 +03:00
|
|
|
// Android 2.3 always returns 0 for playback rate
|
|
|
|
if (!vjs.Html5.canControlPlaybackRate()) {
|
|
|
|
ok('Playback rate is not supported');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-17 00:48:05 +03:00
|
|
|
tech.createEl();
|
|
|
|
|
|
|
|
tech.el().playbackRate = 1.25;
|
|
|
|
strictEqual(tech.playbackRate(), 1.25);
|
|
|
|
|
|
|
|
tech['setPlaybackRate'](0.75);
|
|
|
|
strictEqual(tech.playbackRate(), 0.75);
|
|
|
|
});
|
|
|
|
|
2014-03-18 03:47:47 +03:00
|
|
|
test('patchCanPlayType patches canplaytype with our function, conditionally', function() {
|
2014-03-27 21:19:21 +03:00
|
|
|
// the patch runs automatically so we need to first unpatch
|
|
|
|
vjs.Html5.unpatchCanPlayType();
|
|
|
|
|
2014-03-18 03:47:47 +03:00
|
|
|
var oldAV = vjs.ANDROID_VERSION,
|
|
|
|
video = document.createElement('video'),
|
2014-03-25 02:07:19 +03:00
|
|
|
canPlayType = vjs.TEST_VID.constructor.prototype.canPlayType,
|
2014-03-26 21:58:36 +03:00
|
|
|
patchedCanPlayType,
|
2014-03-18 03:47:47 +03:00
|
|
|
unpatchedCanPlayType;
|
|
|
|
|
2014-03-25 01:00:00 +03:00
|
|
|
vjs.ANDROID_VERSION = 4.0;
|
2014-03-18 03:47:47 +03:00
|
|
|
vjs.Html5.patchCanPlayType();
|
|
|
|
|
|
|
|
notStrictEqual(video.canPlayType, canPlayType, 'original canPlayType and patched canPlayType should not be equal');
|
|
|
|
|
2014-03-26 21:58:36 +03:00
|
|
|
patchedCanPlayType = video.canPlayType;
|
2014-03-18 03:47:47 +03:00
|
|
|
unpatchedCanPlayType = vjs.Html5.unpatchCanPlayType();
|
|
|
|
|
2014-03-26 23:59:04 +03:00
|
|
|
strictEqual(canPlayType, vjs.TEST_VID.constructor.prototype.canPlayType, 'original canPlayType and unpatched canPlayType should be equal');
|
|
|
|
strictEqual(patchedCanPlayType, unpatchedCanPlayType, 'patched canPlayType and function returned from unpatch are equal');
|
2014-03-18 03:47:47 +03:00
|
|
|
|
|
|
|
vjs.ANDROID_VERSION = oldAV;
|
2014-03-26 21:58:36 +03:00
|
|
|
vjs.Html5.unpatchCanPlayType();
|
2014-03-18 03:47:47 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('should return maybe for HLS urls on Android 4.0 or above', function() {
|
|
|
|
var oldAV = vjs.ANDROID_VERSION,
|
|
|
|
video = document.createElement('video');
|
|
|
|
|
2014-03-25 01:00:00 +03:00
|
|
|
vjs.ANDROID_VERSION = 4.0;
|
2014-03-18 03:47:47 +03:00
|
|
|
vjs.Html5.patchCanPlayType();
|
|
|
|
|
2014-03-25 01:00:00 +03:00
|
|
|
strictEqual(video.canPlayType('application/x-mpegurl'), 'maybe', 'android version 4.0 or above should be a maybe for x-mpegurl');
|
|
|
|
strictEqual(video.canPlayType('application/x-mpegURL'), 'maybe', 'android version 4.0 or above should be a maybe for x-mpegURL');
|
|
|
|
strictEqual(video.canPlayType('application/vnd.apple.mpegurl'), 'maybe', 'android version 4.0 or above should be a maybe for vnd.apple.mpegurl');
|
|
|
|
strictEqual(video.canPlayType('application/vnd.apple.mpegURL'), 'maybe', 'android version 4.0 or above should be a maybe for vnd.apple.mpegurl');
|
2014-03-18 03:47:47 +03:00
|
|
|
|
|
|
|
vjs.ANDROID_VERSION = oldAV;
|
2014-03-25 22:32:03 +03:00
|
|
|
vjs.Html5.unpatchCanPlayType();
|
2014-03-18 03:47:47 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('should return a maybe for mp4 on OLD ANDROID', function() {
|
|
|
|
var isOldAndroid = vjs.IS_OLD_ANDROID,
|
|
|
|
video = document.createElement('video');
|
|
|
|
|
|
|
|
vjs.IS_OLD_ANDROID = true;
|
|
|
|
vjs.Html5.patchCanPlayType();
|
|
|
|
|
|
|
|
strictEqual(video.canPlayType('video/mp4'), 'maybe', 'old android should return a maybe for video/mp4');
|
|
|
|
|
|
|
|
vjs.IS_OLD_ANDROID = isOldAndroid;
|
2014-03-25 22:32:03 +03:00
|
|
|
vjs.Html5.unpatchCanPlayType();
|
2014-03-18 03:47:47 +03:00
|
|
|
});
|