MDL-58530 media_videojs: upgrade videojs to 5.18.4

This commit is contained in:
Marina Glancy 2017-04-07 10:59:11 +08:00
parent bd99cb9021
commit 4aaaabb0da
12 changed files with 9035 additions and 6924 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -33,7 +33,8 @@ THE SOFTWARE. */
}(this, function(videojs) { }(this, function(videojs) {
'use strict'; 'use strict';
var Tech = videojs.getComponent('Tech'); var _isOnMobile = videojs.browser.IS_IOS || videojs.browser.IS_ANDROID;
var Tech = videojs.getTech('Tech');
var Youtube = videojs.extend(Tech, { var Youtube = videojs.extend(Tech, {
@ -77,7 +78,7 @@ THE SOFTWARE. */
this.el_.parentNode.className = this.el_.parentNode.className this.el_.parentNode.className = this.el_.parentNode.className
.replace(' vjs-youtube', '') .replace(' vjs-youtube', '')
.replace(' vjs-youtube-mobile', ''); .replace(' vjs-youtube-mobile', '');
this.el_.remove(); this.el_.parentNode.removeChild(this.el_);
//Needs to be called after the YouTube player is destroyed, otherwise there will be a null reference exception //Needs to be called after the YouTube player is destroyed, otherwise there will be a null reference exception
Tech.prototype.dispose.call(this); Tech.prototype.dispose.call(this);
@ -206,6 +207,14 @@ THE SOFTWARE. */
playerVars.theme = this.options_.theme; playerVars.theme = this.options_.theme;
} }
// Allow undocumented options to be passed along via customVars
if (typeof this.options_.customVars !== 'undefined') {
var customVars = this.options_.customVars;
Object.keys(customVars).forEach(function(key) {
playerVars[key] = customVars[key];
});
}
this.activeVideoId = this.url ? this.url.videoId : null; this.activeVideoId = this.url ? this.url.videoId : null;
this.activeList = playerVars.list; this.activeList = playerVars.list;
@ -215,6 +224,7 @@ THE SOFTWARE. */
events: { events: {
onReady: this.onPlayerReady.bind(this), onReady: this.onPlayerReady.bind(this),
onPlaybackQualityChange: this.onPlayerPlaybackQualityChange.bind(this), onPlaybackQualityChange: this.onPlayerPlaybackQualityChange.bind(this),
onPlaybackRateChange: this.onPlayerPlaybackRateChange.bind(this),
onStateChange: this.onPlayerStateChange.bind(this), onStateChange: this.onPlayerStateChange.bind(this),
onError: this.onPlayerError.bind(this) onError: this.onPlayerError.bind(this)
} }
@ -222,13 +232,22 @@ THE SOFTWARE. */
}, },
onPlayerReady: function() { onPlayerReady: function() {
if (this.options_.muted) {
this.ytPlayer.mute();
}
var playbackRates = this.ytPlayer.getAvailablePlaybackRates();
if (playbackRates.length > 1) {
this.featuresPlaybackRate = true;
}
this.playerReady_ = true; this.playerReady_ = true;
this.triggerReady(); this.triggerReady();
if (this.playOnReady) { if (this.playOnReady) {
this.play(); this.play();
} else if (this.cueOnReady) { } else if (this.cueOnReady) {
this.ytPlayer.cueVideoById(this.url.videoId); this.cueVideoById_(this.url.videoId);
this.activeVideoId = this.url.videoId; this.activeVideoId = this.url.videoId;
} }
}, },
@ -237,6 +256,10 @@ THE SOFTWARE. */
}, },
onPlayerPlaybackRateChange: function() {
this.trigger('ratechange');
},
onPlayerStateChange: function(e) { onPlayerStateChange: function(e) {
var state = e.data; var state = e.data;
@ -251,6 +274,7 @@ THE SOFTWARE. */
this.trigger('loadstart'); this.trigger('loadstart');
this.trigger('loadedmetadata'); this.trigger('loadedmetadata');
this.trigger('durationchange'); this.trigger('durationchange');
this.trigger('ratechange');
break; break;
case YT.PlayerState.ENDED: case YT.PlayerState.ENDED:
@ -286,26 +310,55 @@ THE SOFTWARE. */
onPlayerError: function(e) { onPlayerError: function(e) {
this.errorNumber = e.data; this.errorNumber = e.data;
this.trigger('pause');
this.trigger('error'); this.trigger('error');
this.ytPlayer.stopVideo();
}, },
error: function() { error: function() {
var code = 1000 + this.errorNumber; // as smaller codes are reserved
switch (this.errorNumber) { switch (this.errorNumber) {
case 5: case 5:
return { code: 'Error while trying to play the video' }; return { code: code, message: 'Error while trying to play the video' };
case 2: case 2:
case 100: case 100:
return { code: 'Unable to find the video' }; return { code: code, message: 'Unable to find the video' };
case 101: case 101:
case 150: case 150:
return { code: 'Playback on other Websites has been disabled by the video owner.' }; return {
code: code,
message: 'Playback on other Websites has been disabled by the video owner.'
};
} }
return { code: 'YouTube unknown error (' + this.errorNumber + ')' }; return { code: code, message: 'YouTube unknown error (' + this.errorNumber + ')' };
},
loadVideoById_: function(id) {
var options = {
videoId: id
};
if (this.options_.start) {
options.startSeconds = this.options_.start;
}
if (this.options_.end) {
options.endEnd = this.options_.end;
}
this.ytPlayer.loadVideoById(options);
},
cueVideoById_: function(id) {
var options = {
videoId: id
};
if (this.options_.start) {
options.startSeconds = this.options_.start;
}
if (this.options_.end) {
options.endEnd = this.options_.end;
}
this.ytPlayer.cueVideoById(options);
}, },
src: function(src) { src: function(src) {
@ -358,7 +411,7 @@ THE SOFTWARE. */
} }
} else if (this.activeVideoId !== this.url.videoId) { } else if (this.activeVideoId !== this.url.videoId) {
if (this.isReady_) { if (this.isReady_) {
this.ytPlayer.cueVideoById(this.url.videoId); this.cueVideoById_(this.url.videoId);
this.activeVideoId = this.url.videoId; this.activeVideoId = this.url.videoId;
} else { } else {
this.cueOnReady = true; this.cueOnReady = true;
@ -402,7 +455,7 @@ THE SOFTWARE. */
if (this.activeVideoId === this.url.videoId) { if (this.activeVideoId === this.url.videoId) {
this.ytPlayer.playVideo(); this.ytPlayer.playVideo();
} else { } else {
this.ytPlayer.loadVideoById(this.url.videoId); this.loadVideoById_(this.url.videoId);
this.activeVideoId = this.url.videoId; this.activeVideoId = this.url.videoId;
} }
} else { } else {
@ -463,24 +516,11 @@ THE SOFTWARE. */
}, },
seekable: function () { seekable: function () {
if(!this.ytPlayer || !this.ytPlayer.getVideoLoadedFraction) { if(!this.ytPlayer) {
return { return videojs.createTimeRange();
length: 0,
start: function() {
throw new Error('This TimeRanges object is empty');
},
end: function() {
throw new Error('This TimeRanges object is empty');
}
};
} }
var end = this.ytPlayer.getDuration();
return { return videojs.createTimeRange(0, this.ytPlayer.getDuration());
length: this.ytPlayer.getDuration(),
start: function() { return 0; },
end: function() { return end; }
};
}, },
onSeeked: function() { onSeeked: function() {
@ -504,7 +544,6 @@ THE SOFTWARE. */
} }
this.ytPlayer.setPlaybackRate(suggestedRate); this.ytPlayer.setPlaybackRate(suggestedRate);
this.trigger('ratechange');
}, },
duration: function() { duration: function() {
@ -559,24 +598,12 @@ THE SOFTWARE. */
buffered: function() { buffered: function() {
if(!this.ytPlayer || !this.ytPlayer.getVideoLoadedFraction) { if(!this.ytPlayer || !this.ytPlayer.getVideoLoadedFraction) {
return { return videojs.createTimeRange();
length: 0,
start: function() {
throw new Error('This TimeRanges object is empty');
},
end: function() {
throw new Error('This TimeRanges object is empty');
}
};
} }
var end = this.ytPlayer.getVideoLoadedFraction() * this.ytPlayer.getDuration(); var bufferedEnd = this.ytPlayer.getVideoLoadedFraction() * this.ytPlayer.getDuration();
return { return videojs.createTimeRange(0, bufferedEnd);
length: this.ytPlayer.getDuration(),
start: function() { return 0; },
end: function() { return end; }
};
}, },
// TODO: Can we really do something with this on YouTUbe? // TODO: Can we really do something with this on YouTUbe?
@ -626,8 +653,6 @@ THE SOFTWARE. */
return (e === 'video/youtube'); return (e === 'video/youtube');
}; };
var _isOnMobile = videojs.browser.IS_IOS || useNativeControlsOnAndroid();
Youtube.parseUrl = function(url) { Youtube.parseUrl = function(url) {
var result = { var result = {
videoId: null videoId: null
@ -701,14 +726,6 @@ THE SOFTWARE. */
head.appendChild(style); head.appendChild(style);
} }
function useNativeControlsOnAndroid() {
var stockRegex = window.navigator.userAgent.match(/applewebkit\/(\d*).*Version\/(\d*.\d*)/i);
//True only Android Stock Browser on OS versions 4.X and below
//where a Webkit version and a "Version/X.X" String can be found in
//user agent.
return videojs.browser.IS_ANDROID && videojs.browser.ANDROID_VERSION < 5 && stockRegex && stockRegex[2] > 0;
}
Youtube.apiReadyQueue = []; Youtube.apiReadyQueue = [];
loadScript('https://www.youtube.com/iframe_api', apiLoaded); loadScript('https://www.youtube.com/iframe_api', apiLoaded);

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?> <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMid meet"> <svg xmlns="http://www.w3.org/2000/svg">
<defs> <defs>
<font id="VideoJS" horiz-adv-x="1792"> <font id="VideoJS" horiz-adv-x="1792">
<font-face font-family="VideoJS" <font-face font-family="VideoJS"

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Before After
Before After

View file

@ -1,4 +1,4 @@
VideoJS 5.12.6 VideoJS 5.18.4
-------------- --------------
https://github.com/videojs/video.js https://github.com/videojs/video.js

View file

@ -402,6 +402,9 @@ body.vjs-full-window {
.vjs-error .vjs-big-play-button { .vjs-error .vjs-big-play-button {
display: none; } display: none; }
.vjs-has-started.vjs-paused.vjs-show-big-play-button-on-pause .vjs-big-play-button {
display: block; }
.video-js button { .video-js button {
background: none; background: none;
border: none; border: none;
@ -453,8 +456,8 @@ body.vjs-full-window {
text-align: center; text-align: center;
text-transform: lowercase; } text-transform: lowercase; }
.vjs-menu li:focus, .vjs-menu li.vjs-menu-item:focus,
.vjs-menu li:hover { .vjs-menu li.vjs-menu-item:hover {
outline: 0; outline: 0;
background-color: #73859f; background-color: #73859f;
background-color: rgba(115, 133, 159, 0.5); } background-color: rgba(115, 133, 159, 0.5); }
@ -932,9 +935,6 @@ body.vjs-full-window {
.vjs-audio.vjs-has-started .vjs-poster { .vjs-audio.vjs-has-started .vjs-poster {
display: block; } display: block; }
.vjs-controls-disabled .vjs-poster {
display: none; }
.vjs-using-native-controls .vjs-poster { .vjs-using-native-controls .vjs-poster {
display: none; } display: none; }

View file

@ -4,21 +4,21 @@
<location>amd/src/video-lazy.js</location> <location>amd/src/video-lazy.js</location>
<name>VideoJS</name> <name>VideoJS</name>
<license>Apache</license> <license>Apache</license>
<version>5.12.6</version> <version>5.18.4</version>
<licenseversion></licenseversion> <licenseversion></licenseversion>
</library> </library>
<library> <library>
<location>amd/src/Youtube-lazy.js</location> <location>amd/src/Youtube-lazy.js</location>
<name>YouTube Playback Technology for Video.js</name> <name>YouTube Playback Technology for Video.js</name>
<license>MIT</license> <license>MIT</license>
<version>2.1.1</version> <version>2.3.2</version>
<licenseversion></licenseversion> <licenseversion></licenseversion>
</library> </library>
<library> <library>
<location>videojs</location> <location>videojs</location>
<name>VideoJS support files</name> <name>VideoJS support files</name>
<license>Apache</license> <license>Apache</license>
<version>5.12.6</version> <version>5.18.4</version>
<licenseversion></licenseversion> <licenseversion></licenseversion>
</library> </library>
</libraries> </libraries>

View file

@ -18,9 +18,23 @@ videojs.addLanguage("ru",{
"Captions": "Подписи", "Captions": "Подписи",
"captions off": "Подписи выкл.", "captions off": "Подписи выкл.",
"Chapters": "Главы", "Chapters": "Главы",
"Close Modal Dialog": "Закрыть модальное окно",
"Descriptions": "Описания",
"descriptions off": "описания выкл.",
"Audio Track": "Звуковая дорожка",
"You aborted the media playback": "Вы прервали воспроизведение видео", "You aborted the media playback": "Вы прервали воспроизведение видео",
"A network error caused the media download to fail part-way.": "Ошибка сети вызвала сбой во время загрузки видео.", "A network error caused the media download to fail part-way.": "Ошибка сети вызвала сбой во время загрузки видео.",
"The media could not be loaded, either because the server or network failed or because the format is not supported.": "Невозможно загрузить видео из-за сетевого или серверного сбоя либо формат не поддерживается.", "The media could not be loaded, either because the server or network failed or because the format is not supported.": "Невозможно загрузить видео из-за сетевого или серверного сбоя либо формат не поддерживается.",
"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "Воспроизведение видео было приостановлено из-за повреждения либо в связи с тем, что видео использует функции, неподдерживаемые вашим браузером.", "The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "Воспроизведение видео было приостановлено из-за повреждения либо в связи с тем, что видео использует функции, неподдерживаемые вашим браузером.",
"No compatible source was found for this media.": "Совместимые источники для этого видео отсутствуют." "No compatible source was found for this media.": "Совместимые источники для этого видео отсутствуют.",
"The media is encrypted and we do not have the keys to decrypt it.": "Видео в зашифрованном виде, и у нас нет ключей для расшифровки.",
"Play Video": "Воспроизвести видео",
"Close": "Закрыть",
"Modal Window": "Модальное окно",
"This is a modal window": "Это модальное окно.",
"This modal can be closed by pressing the Escape key or activating the close button.": "Модальное окно можно закрыть нажав Esc или кнопку закрытия окна.",
", opens captions settings dialog": ", откроется диалог настройки подписей",
", opens subtitles settings dialog": ", откроется диалог настройки субтитров",
", opens descriptions settings dialog": ", откроется диалог настройки описаний",
", selected": ", выбрано"
}); });

View file

@ -18,9 +18,23 @@ videojs.addLanguage("uk",{
"Captions": "Підписи", "Captions": "Підписи",
"captions off": "Без підписів", "captions off": "Без підписів",
"Chapters": "Розділи", "Chapters": "Розділи",
"Close Modal Dialog": "Закрити модальний діалог",
"Descriptions": "Описи",
"descriptions off": "Без описів",
"Audio Track": "Аудіодоріжка",
"You aborted the media playback": "Ви припинили відтворення відео", "You aborted the media playback": "Ви припинили відтворення відео",
"A network error caused the media download to fail part-way.": "Помилка мережі викликала збій під час завантаження відео.", "A network error caused the media download to fail part-way.": "Помилка мережі викликала збій під час завантаження відео.",
"The media could not be loaded, either because the server or network failed or because the format is not supported.": "Неможливо завантажити відео через мережевий чи серверний збій або формат не підтримується.", "The media could not be loaded, either because the server or network failed or because the format is not supported.": "Неможливо завантажити відео через мережевий чи серверний збій або формат не підтримується.",
"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "Відтворення відео було припинено через пошкодження або у зв'язку з тим, що відео використовує функції, які не підтримуються вашим браузером.", "The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "Відтворення відео було припинено через пошкодження або у зв'язку з тим, що відео використовує функції, які не підтримуються вашим браузером.",
"No compatible source was found for this media.": "Сумісні джерела для цього відео відсутні." "No compatible source was found for this media.": "Сумісні джерела для цього відео відсутні.",
"The media is encrypted and we do not have the keys to decrypt it.": "Відео в зашифрованому вигляді, і ми не маємо ключі для розшифровки.",
"Play Video": "Відтворити відео",
"Close": "Закрити",
"Modal Window": "Модальне вікно",
"This is a modal window": "Це модальне вікно.",
"This modal can be closed by pressing the Escape key or activating the close button.": "Модальне вікно можна закрити, натиснувши клавішу Esc або кнопку закриття вікна.",
", opens captions settings dialog": ", відкриється діалогове вікно налаштування підписів",
", opens subtitles settings dialog": ", відкриється діалогове вікно налаштування субтитрів",
", opens descriptions settings dialog": ", відкриється діалогове вікно налаштування описів",
", selected": ", обраний"
}); });

View file

@ -18,10 +18,23 @@ videojs.addLanguage("zh-TW",{
"Captions": "內嵌字幕", "Captions": "內嵌字幕",
"captions off": "關閉內嵌字幕", "captions off": "關閉內嵌字幕",
"Chapters": "章節", "Chapters": "章節",
"Close Modal Dialog": "關閉對話框",
"Descriptions": "描述",
"descriptions off": "關閉描述",
"Audio Track": "音軌",
"You aborted the media playback": "影片播放已終止", "You aborted the media playback": "影片播放已終止",
"A network error caused the media download to fail part-way.": "網路錯誤導致影片下載失敗。", "A network error caused the media download to fail part-way.": "網路錯誤導致影片下載失敗。",
"The media could not be loaded, either because the server or network failed or because the format is not supported.": "影片因格式不支援或者伺服器或網路的問題無法載入。", "The media could not be loaded, either because the server or network failed or because the format is not supported.": "影片因格式不支援或者伺服器或網路的問題無法載入。",
"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "由於影片檔案損毀或是該影片使用了您的瀏覽器不支援的功能,播放終止。", "The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "由於影片檔案損毀或是該影片使用了您的瀏覽器不支援的功能,播放終止。",
"No compatible source was found for this media.": "無法找到相容此影片的來源。", "No compatible source was found for this media.": "無法找到相容此影片的來源。",
"The media is encrypted and we do not have the keys to decrypt it.": "影片已加密,無法解密。" "The media is encrypted and we do not have the keys to decrypt it.": "影片已加密,無法解密。",
"Play Video": "播放影片",
"Close": "關閉",
"Modal Window": "對話框",
"This is a modal window": "這是一個對話框",
"This modal can be closed by pressing the Escape key or activating the close button.": "可以按ESC按鍵或啟用關閉按鈕來關閉此對話框。",
", opens captions settings dialog": ", 開啟標題設定對話框",
", opens subtitles settings dialog": ", 開啟字幕設定對話框",
", opens descriptions settings dialog": ", 開啟描述設定對話框",
", selected": ", 選擇"
}); });