1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-27 11:22:06 +02:00

cleanup and fixed options shadowing in player

This commit is contained in:
Matthew McClure 2015-04-03 15:15:42 -07:00
parent 44953cf99b
commit f3036dd528
8 changed files with 25 additions and 29 deletions

View File

@ -43,7 +43,7 @@ var videojs = function(id, options, ready){
// If options or ready funtion are passed, warn // If options or ready funtion are passed, warn
if (options) { 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) { if (ready) {

View File

@ -40,7 +40,7 @@ var fixEvent = function(event) {
if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation') { if (key !== 'layerX' && key !== 'layerY' && key !== 'keyLocation') {
// Chrome 32+ warns if you try to copy deprecated returnValue, but // Chrome 32+ warns if you try to copy deprecated returnValue, but
// we still want to if preventDefault isn't supported (IE8). // we still want to if preventDefault isn't supported (IE8).
if (!(key == 'returnValue' && old.preventDefault)) { if (!(key === 'returnValue' && old.preventDefault)) {
event[key] = old[key]; event[key] = old[key];
} }
} }

View File

@ -62,7 +62,7 @@ let specApi = apiMap[0];
let browserApi; let browserApi;
// determine the supported set of functions // 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 // check for exitFullscreen function
if (apiMap[i][1] in document) { if (apiMap[i][1] in document) {
browserApi = apiMap[i]; browserApi = apiMap[i];

View File

@ -24,10 +24,7 @@ var Flash = MediaTechController.extend({
init: function(player, options, ready){ init: function(player, options, ready){
MediaTechController.call(this, player, options, ready); MediaTechController.call(this, player, options, ready);
let source = options['source']; let { source, parentEl } = options;
// Which element to embed in
let parentEl = options['parentEl'];
// Create a temporary element to be replaced by swf object // Create a temporary element to be replaced by swf object
let placeHolder = this.el_ = Lib.createEl('div', { id: player.id() + '_temp_flash' }); let placeHolder = this.el_ = Lib.createEl('div', { id: player.id() + '_temp_flash' });
@ -241,7 +238,7 @@ Flash.nativeSourceHandler.canHandleSource = function(source){
var type; var type;
function guessMimeType(src) { function guessMimeType(src) {
var ext = vjs.getFileExtension(src); var ext = Lib.getFileExtension(src);
if (ext) { if (ext) {
return 'video/' + ext; return 'video/' + ext;
} }

View File

@ -490,7 +490,7 @@ Html5.nativeSourceHandler.canHandleSource = function(source){
return canPlayType(source.type); return canPlayType(source.type);
} else if (source.src) { } else if (source.src) {
// If no type, fall back to checking 'video/[EXTENSION]' // If no type, fall back to checking 'video/[EXTENSION]'
ext = vjs.getFileExtension(source.src); ext = Lib.getFileExtension(source.src);
return canPlayType('video/'+ext); return canPlayType('video/'+ext);
} }

View File

@ -3,7 +3,7 @@ import * as Lib from './lib.js';
import * as Events from './events.js'; import * as Events from './events.js';
import FullscreenApi from './fullscreen-api.js'; import FullscreenApi from './fullscreen-api.js';
import MediaError from './media-error.js'; import MediaError from './media-error.js';
import options from './options.js'; import Options from './options.js';
import JSON from './json.js'; import JSON from './json.js';
import window from 'global/window'; import window from 'global/window';
import document from 'global/document'; import document from 'global/document';
@ -68,10 +68,10 @@ let Player = Component.extend({
options = Lib.obj.merge(this.getTagSettings(tag), options); options = Lib.obj.merge(this.getTagSettings(tag), options);
// Update Current Language // Update Current Language
this.language_ = options['language'] || options['language']; this.language_ = options['language'] || Options['language'];
// Update Supported Languages // Update Supported Languages
this.languages_ = options['languages'] || options['languages']; this.languages_ = options['languages'] || Options['languages'];
// Cache for video property values. // Cache for video property values.
this.cache_ = {}; this.cache_ = {};
@ -181,7 +181,7 @@ Player.prototype.languages = function(){
* @type {Object} * @type {Object}
* @private * @private
*/ */
Player.prototype.options_ = options; Player.prototype.options_ = Options;
/** /**
* Destroys the video player and does any necessary cleanup * Destroys the video player and does any necessary cleanup

View File

@ -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 () { 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.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.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('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'); equal('', canHandleSource({src: 'test.video.wgg'}), 'should return empty string if it can not play the video');
}); });

View File

@ -408,22 +408,22 @@ test('should loop through each element of an array', function() {
//getFileExtension tests //getFileExtension tests
test('should get the file extension of the passed path', function() { test('should get the file extension of the passed path', function() {
equal(vjs.getFileExtension('/foo/bar/test.video.wgg'), 'wgg'); equal(Lib.getFileExtension('/foo/bar/test.video.wgg'), 'wgg');
equal(vjs.getFileExtension('test./video.mp4'), 'mp4'); equal(Lib.getFileExtension('test./video.mp4'), 'mp4');
equal(vjs.getFileExtension('.bar/test.video.m4v'), 'm4v'); equal(Lib.getFileExtension('.bar/test.video.m4v'), 'm4v');
equal(vjs.getFileExtension('foo/.bar/test.video.flv'), 'flv'); equal(Lib.getFileExtension('foo/.bar/test.video.flv'), 'flv');
equal(vjs.getFileExtension('foo/.bar/test.video.flv?foo=bar'), 'flv'); equal(Lib.getFileExtension('foo/.bar/test.video.flv?foo=bar'), 'flv');
equal(vjs.getFileExtension('http://www.test.com/video.mp4'), 'mp4'); equal(Lib.getFileExtension('http://www.test.com/video.mp4'), 'mp4');
equal(vjs.getFileExtension('http://foo/bar/test.video.wgg'), 'wgg'); equal(Lib.getFileExtension('http://foo/bar/test.video.wgg'), 'wgg');
//edge cases //edge cases
equal(vjs.getFileExtension('http://...'), ''); equal(Lib.getFileExtension('http://...'), '');
equal(vjs.getFileExtension('foo/.bar/testvideo'), ''); equal(Lib.getFileExtension('foo/.bar/testvideo'), '');
equal(vjs.getFileExtension(''), ''); equal(Lib.getFileExtension(''), '');
equal(vjs.getFileExtension(null), ''); equal(Lib.getFileExtension(null), '');
equal(vjs.getFileExtension(undefined), ''); equal(Lib.getFileExtension(undefined), '');
//with capital letters //with capital letters
equal(vjs.getFileExtension('test.video.MP4'), 'mp4'); equal(Lib.getFileExtension('test.video.MP4'), 'mp4');
equal(vjs.getFileExtension('test.video.FLV'), 'flv'); equal(Lib.getFileExtension('test.video.FLV'), 'flv');
}); });