From 918ee040e110b8d32c465d394722ba048ed581c4 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Fri, 12 Jul 2013 16:05:25 -0400 Subject: [PATCH 1/2] Allow setting a custom incompatible video message. fixes #636 --- src/js/player.js | 12 +++++++++++- test/unit/player.js | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/js/player.js b/src/js/player.js index 07f853c723..3d64220c0e 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -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 Chrome or download the ' + + 'latest Adobe Flash Player.'; + } + this.el_.appendChild(vjs.createEl('p', { - innerHTML: 'Sorry, no compatible source and playback technology were found for this video. Try using another browser like Chrome or download the latest Adobe Flash Player.' + innerHTML: incompatibleMessage })); } diff --git a/test/unit/player.js b/test/unit/player.js index 18fb8d0e26..3be6be399d 100644 --- a/test/unit/player.js +++ b/test/unit/player.js @@ -247,3 +247,23 @@ test('should set controls and trigger event', function() { // player.requestFullScreen(); // }); +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 html = + ''; + + fixture.innerHTML += html; + + 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(); +}); From ff9165b7dafa6d4f6c9108126853f6b5e1a3cc51 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Mon, 5 Aug 2013 14:19:20 -0400 Subject: [PATCH 2/2] Default incompatibility msg w/ other global options fixes #636 --- src/js/core.js | 8 +++++++- src/js/player.js | 12 +----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/js/core.js b/src/js/core.js index 28f047765d..eb58a67d00 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -89,7 +89,13 @@ vjs.options = { 'loadingSpinner': {}, 'bigPlayButton': {}, 'controlBar': {} - } + }, + + // Default message to show when a video cannot be played. + incompatibleVideoMessage: 'Sorry, no compatible source and playback ' + + 'technology were found for this video. Try using another browser ' + + 'like Chrome or download the ' + + 'latest Adobe Flash Player.' }; // Set CDN Version of swf diff --git a/src/js/player.js b/src/js/player.js index 3d64220c0e..ac648f130e 100644 --- a/src/js/player.js +++ b/src/js/player.js @@ -739,18 +739,8 @@ 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 Chrome or download the ' + - 'latest Adobe Flash Player.'; - } - this.el_.appendChild(vjs.createEl('p', { - innerHTML: incompatibleMessage + innerHTML: this.options()['incompatibleVideoMessage'] })); }