Skip to content

Commit

Permalink
cleanup and fixed options shadowing in player
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcc committed Apr 3, 2015
1 parent 44953cf commit f3036dd
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/fullscreen-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
7 changes: 2 additions & 5 deletions src/js/media/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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_ = {};
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/unit/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

28 changes: 14 additions & 14 deletions test/unit/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

0 comments on commit f3036dd

Please sign in to comment.