Chromium Code Reviews| Index: ui/file_manager/video_player/js/video_player.js |
| diff --git a/ui/file_manager/video_player/js/video_player.js b/ui/file_manager/video_player/js/video_player.js |
| index bed41ba51340d46f09cffffeb3e3bf4c4cd10e94..a070db4a4cba29945c7c0139b9cc91f5ce4419d3 100644 |
| --- a/ui/file_manager/video_player/js/video_player.js |
| +++ b/ui/file_manager/video_player/js/video_player.js |
| @@ -376,8 +376,11 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { |
| this.videoElement_ = document.createElement('video'); |
| getRequiredElement('video-container').appendChild(this.videoElement_); |
| + var videoUrl = video.toURL(); |
| this.controls.attachMedia(this.videoElement_); |
| - this.videoElement_.src = video.toURL(); |
| + var source = document.createElement('source'); |
| + source.src = videoUrl; |
| + this.videoElement_.appendChild(source); |
| media.isAvailableForCast().then(function(result) { |
| if (result) |
| @@ -388,9 +391,18 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { |
| videoPlayerElement.setAttribute('castable', true); |
| }); |
| - videoElementInitializePromise = Promise.resolve(); |
| + videoElementInitializePromise = this.loadSubtitles_(videoUrl) |
| + .then(function(subltitleUrl) { |
| + if (subltitleUrl) { |
| + var track = document.createElement('track'); |
| + track.src = subltitleUrl; |
| + track.kind = 'subtitles'; |
| + track.default = true; |
| + this.videoElement_.appendChild(track); |
| + } |
| + return Promise.resolve(); |
|
yoshiki
2016/03/14 04:10:52
nit: returning resolve is unnecessary. please remo
ryoh
2016/03/14 13:45:25
Done.
|
| + }.bind(this)); |
| } |
| - |
| videoElementInitializePromise |
| .then(function() { |
| var handler = function(currentPos) { |
| @@ -414,7 +426,6 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { |
| this.updateInactivityWatcherState_(); |
| }.wrap(this)); |
| - this.videoElement_.load(); |
|
ryoh
2016/03/11 15:11:58
Why do we need this line?
It seems 'loadedmetadata
yoshiki
2016/03/14 04:10:52
According to the spec, we need to call load() unle
ryoh
2016/03/14 13:45:25
Yeah, if we **modified** src attribute, you have t
|
| callback(); |
| }.bind(this)) |
| // In case of error. |
| @@ -432,6 +443,19 @@ VideoPlayer.prototype.loadVideo_ = function(video, opt_callback) { |
| }.wrap(this)); |
| }; |
| +VideoPlayer.prototype.loadSubtitles_ = function(url) { |
|
yoshiki
2016/03/14 04:10:52
nit: Please write a JSdoc (short description of th
ryoh
2016/03/14 13:45:25
Done.
|
| + var baseUrl = util.splitExtension(url)[0]; |
| + var resolveLocalFileSystem = function(extension) { |
|
yoshiki
2016/03/14 04:10:52
"resolveLocalFileSystem" looks confusing with reso
ryoh
2016/03/14 13:45:25
Sounds nice! Thank you.
|
| + return new Promise( |
| + window.webkitResolveLocalFileSystemURL.bind(null, baseUrl + extension)); |
| + } |
|
yoshiki
2016/03/14 04:10:52
nit: semicolon
ryoh
2016/03/14 13:45:25
Done.
|
| + return resolveLocalFileSystem('.vtt').then(function(subtitle) { |
| + return subtitle.toURL(); |
| + }).catch(function() { |
| + return ''; |
| + }); |
| +}; |
| + |
| /** |
| * Plays the first video. |
| */ |