Skip to content

Commit

Permalink
Allow setting a custom incompatible video message. fixes videojs#636
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn committed Jul 12, 2013
1 parent fdf7f4f commit 04b2598
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
12 changes: 11 additions & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,18 @@ vjs.Player.prototype.src = function(source){
this.loadTech(techName, source);
}
} else {
var incompatibleMessage;
if (videojs.options['incompatibleVideoMessage']) {
incompatibleMessage = vjs.options['incompatibleVideoMessage'];
} else {
incompatibleMessage = 'Sorry, no compatible source and playback ' +
'technology were found for this video. Try using another browser ' +
'like <a href="http://bit.ly/ccMUEC">Chrome</a> or download the ' +
'latest <a href="http://adobe.ly/mwfN1">Adobe Flash Player</a>.';
}

this.el_.appendChild(vjs.createEl('p', {
innerHTML: 'Sorry, no compatible source and playback technology were found for this video. Try using another browser like <a href="http://bit.ly/ccMUEC">Chrome</a> or download the latest <a href="http://adobe.ly/mwfN1">Adobe Flash Player</a>.'
innerHTML: incompatibleMessage
}));
}

Expand Down
33 changes: 17 additions & 16 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ test('should get tag, source, and track settings', function(){

player.dispose();


ok(tag['player'] !== player, 'tag player ref killed');
ok(tag['player'] === null, 'tag player ref killed');
ok(!vjs.players['example_1'], 'global player ref killed');
ok(player.el() === null, 'player el killed');
});
Expand Down Expand Up @@ -229,21 +228,23 @@ test('should set controls and trigger event', function() {
player.dispose();
});

// Can't figure out how to test fullscreen events with tests
// Browsers aren't triggering the events at least
// asyncTest('should trigger the fullscreenchange event', function() {
// expect(3);
test('should use custom message when encountering an unsupported video type',
function() {
videojs.options['incompatibleVideoMessage'] = 'Video no go';
var fixture = document.getElementById('qunit-fixture');

// var player = PlayerTest.makePlayer();
// player.on('fullscreenchange', function(){
// ok(true, 'fullscreenchange event fired');
// ok(this.isFullScreen === true, 'isFullScreen is true');
// ok(this.el().className.indexOf('vjs-fullscreen') !== -1, 'vjs-fullscreen class added');
var html =
'<video id="example_1">' +
'<source src="fake.foo" type="video/foo">' +
'</video>';

// player.dispose();
// start();
// });
fixture.innerHTML += html;

// player.requestFullScreen();
// });
var tag = document.getElementById('example_1');
var player = new vjs.Player(tag);

var incompatibilityMessage = player.el().getElementsByTagName('p')[0];
equal(incompatibilityMessage.textContent, 'Video no go');

player.dispose();
});

0 comments on commit 04b2598

Please sign in to comment.