|
67 | 67 |
|
68 | 68 | this.media = media; |
69 | 69 | if ($(media).length === 0) { |
70 | | - this.provideFallback('ERROR: No media specified.'); |
| 70 | + this.provideFallback(); |
71 | 71 | return; |
72 | 72 | } |
73 | 73 |
|
|
441 | 441 | } |
442 | 442 | else { |
443 | 443 | // can't continue loading player with no text |
444 | | - thisObj.provideFallback('ERROR: Failed to load translation table'); |
| 444 | + thisObj.provideFallback(); |
445 | 445 | } |
446 | 446 | } |
447 | 447 | ); |
|
455 | 455 | this.reinitialize().then(function () { |
456 | 456 | if (!thisObj.player) { |
457 | 457 | // No player for this media, show last-line fallback. |
458 | | - thisObj.provideFallback('Unable to play media'); |
| 458 | + thisObj.provideFallback(); |
459 | 459 | } |
460 | 460 | else { |
461 | 461 | thisObj.setupInstance().then(function () { |
|
803 | 803 | this.mediaType = 'video'; |
804 | 804 | } |
805 | 805 | else { |
806 | | - this.mediaType = this.$media.get(0).tagName; |
807 | | - errorMsg = 'Media player initialized with ' + this.mediaType + '#' + this.mediaId + '. '; |
808 | | - errorMsg += 'Expecting an HTML5 audio or video element.'; |
809 | | - this.provideFallback(errorMsg); |
| 806 | + // Able Player was initialized with some element other than <video> or <audio> |
| 807 | + this.provideFallback(); |
810 | 808 | deferred.fail(); |
811 | 809 | return promise; |
812 | 810 | } |
|
816 | 814 | this.player = this.getPlayer(); |
817 | 815 | if (!this.player) { |
818 | 816 | // an error was generated in getPlayer() |
819 | | - this.provideFallback(this.error); |
| 817 | + this.provideFallback(); |
820 | 818 | } |
821 | 819 | this.setIconType(); |
822 | 820 | this.setDimensions(); |
|
1068 | 1066 | thisObj.showSearchResults(); |
1069 | 1067 | }, |
1070 | 1068 | function() { // initPlayer fail |
1071 | | - thisObj.provideFallback(this.error); |
| 1069 | + thisObj.provideFallback(); |
1072 | 1070 | } |
1073 | 1071 | ); |
1074 | 1072 | }); |
|
1292 | 1290 | }, |
1293 | 1291 | error: function(jqXHR, textStatus, errorThrown) { |
1294 | 1292 | // Loading the JW Player failed |
1295 | | - this.error = 'Failed to load JW Player.'; |
1296 | 1293 | deferred.reject(); |
1297 | 1294 | } |
1298 | 1295 | }); |
|
1327 | 1324 | var i, sourceType, $newItem; |
1328 | 1325 | if (this.youTubeId) { |
1329 | 1326 | if (this.mediaType !== 'video') { |
1330 | | - this.error = 'To play a YouTube video, use the <video> tag.'; |
| 1327 | + // attempting to play a YouTube video using an element other than <video> |
1331 | 1328 | return null; |
1332 | 1329 | } |
1333 | 1330 | else { |
|
1341 | 1338 | // the user wants to test the fallback player, or |
1342 | 1339 | // the user is using an older version of IE or IOS, |
1343 | 1340 | // both of which had buggy implementation of HTML5 video |
1344 | | - if (this.fallback === 'jw' && this.jwCanPlay()) { |
1345 | | - return 'jw'; |
| 1341 | + if (this.fallback === 'jw') { |
| 1342 | + if (this.jwCanPlay()) { |
| 1343 | + return 'jw'; |
| 1344 | + } |
| 1345 | + else { |
| 1346 | + // JW Player is available as fallback, but can't play this source file |
| 1347 | + return null; |
| 1348 | + } |
1346 | 1349 | } |
1347 | 1350 | else { |
1348 | | - this.error = 'The fallback player (JW Player) is unable to play the available media file.'; |
| 1351 | + // browser doesn't support HTML5 video and there is no fallback player |
1349 | 1352 | return null; |
1350 | 1353 | } |
1351 | 1354 | } |
1352 | 1355 | else if (this.media.canPlayType) { |
1353 | 1356 | return 'html5'; |
1354 | 1357 | } |
1355 | 1358 | else { |
1356 | | - this.error = 'This browser does not support the available media file.'; |
| 1359 | + // Browser does not support the available media file |
1357 | 1360 | return null; |
1358 | 1361 | } |
1359 | 1362 | }; |
|
3803 | 3806 | } |
3804 | 3807 | }; |
3805 | 3808 |
|
3806 | | - AblePlayer.prototype.provideFallback = function(reason) { |
| 3809 | + AblePlayer.prototype.provideFallback = function() { |
3807 | 3810 |
|
3808 | 3811 | // provide ultimate fallback for users who are unable to play the media |
3809 | | - // reason is a specific error message |
3810 | | - // if reason is 'NO SUPPORT', use standard text from translation file |
| 3812 | + // If there is HTML content nested within the media element, display that |
| 3813 | + // Otherwise, display standard localized error text |
3811 | 3814 |
|
3812 | 3815 | var $fallbackDiv, width, mediaClone, fallback, fallbackText, |
3813 | 3816 | showBrowserList, browsers, i, b, browserList; |
|
3839 | 3842 | if (fallback.length) { |
3840 | 3843 | $fallbackDiv.html(fallback); |
3841 | 3844 | } |
3842 | | - else if (reason == 'NO SUPPORT') { |
3843 | | - // not using a supporting browser; use standard text from translation file |
| 3845 | + else { |
| 3846 | + // use standard localized error message |
3844 | 3847 | fallbackText = this.tt.fallbackError1 + ' ' + this.tt[this.mediaType] + '. '; |
3845 | 3848 | fallbackText += this.tt.fallbackError2 + ':'; |
3846 | 3849 | fallback = $('<p>').text(fallbackText); |
3847 | 3850 | $fallbackDiv.html(fallback); |
3848 | 3851 | showBrowserList = true; |
3849 | 3852 | } |
3850 | | - else { |
3851 | | - // show the reason |
3852 | | - $fallbackDiv.text(reason); |
3853 | | - } |
3854 | 3853 |
|
3855 | 3854 | if (showBrowserList) { |
3856 | 3855 | browserList = $('<ul>'); |
|
0 commit comments