mirror of
https://github.com/videojs/video.js.git
synced 2025-01-13 10:32:26 +02:00
cleanup and fixed options shadowing in player
This commit is contained in:
parent
44953cf99b
commit
f3036dd528
@ -43,7 +43,7 @@ var videojs = function(id, options, ready){
|
||||
|
||||
// If options or ready funtion are passed, warn
|
||||
if (options) {
|
||||
Lib.log.warn ('Player "' + id + '" is already initialised. Options will not be applied.');
|
||||
Lib.log.warn('Player "' + id + '" is already initialised. Options will not be applied.');
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
|
@ -40,7 +40,7 @@ var fixEvent = function(event) {
|
||||
if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation') {
|
||||
// Chrome 32+ warns if you try to copy deprecated returnValue, but
|
||||
// we still want to if preventDefault isn't supported (IE8).
|
||||
if (!(key == 'returnValue' && old.preventDefault)) {
|
||||
if (!(key === 'returnValue' && old.preventDefault)) {
|
||||
event[key] = old[key];
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ let specApi = apiMap[0];
|
||||
let browserApi;
|
||||
|
||||
// determine the supported set of functions
|
||||
for (let i=0; i<apiMap.length; i++) {
|
||||
for (let i = 0; i < apiMap.length; i++) {
|
||||
// check for exitFullscreen function
|
||||
if (apiMap[i][1] in document) {
|
||||
browserApi = apiMap[i];
|
||||
|
@ -24,10 +24,7 @@ var Flash = MediaTechController.extend({
|
||||
init: function(player, options, ready){
|
||||
MediaTechController.call(this, player, options, ready);
|
||||
|
||||
let source = options['source'];
|
||||
|
||||
// Which element to embed in
|
||||
let parentEl = options['parentEl'];
|
||||
let { source, parentEl } = options;
|
||||
|
||||
// Create a temporary element to be replaced by swf object
|
||||
let placeHolder = this.el_ = Lib.createEl('div', { id: player.id() + '_temp_flash' });
|
||||
@ -241,7 +238,7 @@ Flash.nativeSourceHandler.canHandleSource = function(source){
|
||||
var type;
|
||||
|
||||
function guessMimeType(src) {
|
||||
var ext = vjs.getFileExtension(src);
|
||||
var ext = Lib.getFileExtension(src);
|
||||
if (ext) {
|
||||
return 'video/' + ext;
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ Html5.nativeSourceHandler.canHandleSource = function(source){
|
||||
return canPlayType(source.type);
|
||||
} else if (source.src) {
|
||||
// If no type, fall back to checking 'video/[EXTENSION]'
|
||||
ext = vjs.getFileExtension(source.src);
|
||||
ext = Lib.getFileExtension(source.src);
|
||||
|
||||
return canPlayType('video/'+ext);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import * as Lib from './lib.js';
|
||||
import * as Events from './events.js';
|
||||
import FullscreenApi from './fullscreen-api.js';
|
||||
import MediaError from './media-error.js';
|
||||
import options from './options.js';
|
||||
import Options from './options.js';
|
||||
import JSON from './json.js';
|
||||
import window from 'global/window';
|
||||
import document from 'global/document';
|
||||
@ -68,10 +68,10 @@ let Player = Component.extend({
|
||||
options = Lib.obj.merge(this.getTagSettings(tag), options);
|
||||
|
||||
// Update Current Language
|
||||
this.language_ = options['language'] || options['language'];
|
||||
this.language_ = options['language'] || Options['language'];
|
||||
|
||||
// Update Supported Languages
|
||||
this.languages_ = options['languages'] || options['languages'];
|
||||
this.languages_ = options['languages'] || Options['languages'];
|
||||
|
||||
// Cache for video property values.
|
||||
this.cache_ = {};
|
||||
@ -181,7 +181,7 @@ Player.prototype.languages = function(){
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
Player.prototype.options_ = options;
|
||||
Player.prototype.options_ = Options;
|
||||
|
||||
/**
|
||||
* Destroys the video player and does any necessary cleanup
|
||||
|
@ -166,10 +166,9 @@ test('should have the source handler interface', function() {
|
||||
});
|
||||
|
||||
test('canHandleSource should be able to work with src objects without a type', function () {
|
||||
var canHandleSource = vjs.Flash.nativeSourceHandler.canHandleSource;
|
||||
var canHandleSource = Flash.nativeSourceHandler.canHandleSource;
|
||||
equal('maybe', canHandleSource({src: 'test.video.mp4'}), 'should guess that it is a mp4 video');
|
||||
equal('maybe', canHandleSource({src: 'test.video.m4v'}), 'should guess that it is a m4v video');
|
||||
equal('maybe', canHandleSource({src: 'test.video.flv'}), 'should guess that it is a flash video');
|
||||
equal('', canHandleSource({src: 'test.video.wgg'}), 'should return empty string if it can not play the video');
|
||||
});
|
||||
|
||||
|
@ -408,22 +408,22 @@ test('should loop through each element of an array', function() {
|
||||
|
||||
//getFileExtension tests
|
||||
test('should get the file extension of the passed path', function() {
|
||||
equal(vjs.getFileExtension('/foo/bar/test.video.wgg'), 'wgg');
|
||||
equal(vjs.getFileExtension('test./video.mp4'), 'mp4');
|
||||
equal(vjs.getFileExtension('.bar/test.video.m4v'), 'm4v');
|
||||
equal(vjs.getFileExtension('foo/.bar/test.video.flv'), 'flv');
|
||||
equal(vjs.getFileExtension('foo/.bar/test.video.flv?foo=bar'), 'flv');
|
||||
equal(vjs.getFileExtension('http://www.test.com/video.mp4'), 'mp4');
|
||||
equal(vjs.getFileExtension('http://foo/bar/test.video.wgg'), 'wgg');
|
||||
equal(Lib.getFileExtension('/foo/bar/test.video.wgg'), 'wgg');
|
||||
equal(Lib.getFileExtension('test./video.mp4'), 'mp4');
|
||||
equal(Lib.getFileExtension('.bar/test.video.m4v'), 'm4v');
|
||||
equal(Lib.getFileExtension('foo/.bar/test.video.flv'), 'flv');
|
||||
equal(Lib.getFileExtension('foo/.bar/test.video.flv?foo=bar'), 'flv');
|
||||
equal(Lib.getFileExtension('http://www.test.com/video.mp4'), 'mp4');
|
||||
equal(Lib.getFileExtension('http://foo/bar/test.video.wgg'), 'wgg');
|
||||
|
||||
//edge cases
|
||||
equal(vjs.getFileExtension('http://...'), '');
|
||||
equal(vjs.getFileExtension('foo/.bar/testvideo'), '');
|
||||
equal(vjs.getFileExtension(''), '');
|
||||
equal(vjs.getFileExtension(null), '');
|
||||
equal(vjs.getFileExtension(undefined), '');
|
||||
equal(Lib.getFileExtension('http://...'), '');
|
||||
equal(Lib.getFileExtension('foo/.bar/testvideo'), '');
|
||||
equal(Lib.getFileExtension(''), '');
|
||||
equal(Lib.getFileExtension(null), '');
|
||||
equal(Lib.getFileExtension(undefined), '');
|
||||
|
||||
//with capital letters
|
||||
equal(vjs.getFileExtension('test.video.MP4'), 'mp4');
|
||||
equal(vjs.getFileExtension('test.video.FLV'), 'flv');
|
||||
equal(Lib.getFileExtension('test.video.MP4'), 'mp4');
|
||||
equal(Lib.getFileExtension('test.video.FLV'), 'flv');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user