Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1047)

Unified Diff: ui/file_manager/video_player/js/media_controls.js

Issue 537863002: Video Player: fix misc bugs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & fix bugs Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/video_player/js/media_controls.js
diff --git a/ui/file_manager/video_player/js/media_controls.js b/ui/file_manager/video_player/js/media_controls.js
index d38fdce4d0729b32036aee142076535ef2378971..8d63495b2e60d3e47deef5da9cfb806d94d8ee51 100644
--- a/ui/file_manager/video_player/js/media_controls.js
+++ b/ui/file_manager/video_player/js/media_controls.js
@@ -24,6 +24,8 @@ function MediaControls(containerElement, onMediaError) {
this.onMediaDurationBound_ = this.onMediaDuration_.bind(this);
this.onMediaProgressBound_ = this.onMediaProgress_.bind(this);
this.onMediaError_ = onMediaError || function() {};
+
+ this.savedVolume_ = 1; // 100% volume.
}
/**
@@ -133,6 +135,9 @@ MediaControls.prototype.enableControls_ = function(selector, on) {
* Play the media.
*/
MediaControls.prototype.play = function() {
+ if (!this.media_)
+ return; // Media is detached.
+
this.media_.play();
};
@@ -140,6 +145,9 @@ MediaControls.prototype.play = function() {
* Pause the media.
*/
MediaControls.prototype.pause = function() {
+ if (!this.media_)
+ return; // Media is detached.
+
this.media_.pause();
};
@@ -230,6 +238,9 @@ MediaControls.prototype.displayProgress_ = function(current, duration) {
* @private
*/
MediaControls.prototype.onProgressChange_ = function(value) {
+ if (!this.media_)
+ return; // Media is detached.
+
if (!this.media_.seekable || !this.media_.duration) {
console.error('Inconsistent media state');
return;
@@ -246,7 +257,7 @@ MediaControls.prototype.onProgressChange_ = function(value) {
*/
MediaControls.prototype.onProgressDrag_ = function(on) {
if (!this.media_)
- return;
+ return; // Media is detached.
if (on) {
this.resumeAfterDrag_ = this.isPlaying();
@@ -315,6 +326,9 @@ MediaControls.getVolumeLevel_ = function(value) {
* @private
*/
MediaControls.prototype.onVolumeChange_ = function(value) {
+ if (!this.media_)
+ return; // Media is detached.
+
this.media_.volume = value;
this.soundButton_.setAttribute('level', MediaControls.getVolumeLevel_(value));
};
@@ -353,7 +367,7 @@ MediaControls.prototype.attachMedia = function(mediaElement) {
this.onMediaProgress_();
if (this.volume_) {
/* Copy the user selected volume to the new media element. */
- this.media_.volume = this.volume_.getValue();
+ this.savedVolume_ = this.media_.volume = this.volume_.getValue();
}
};
@@ -419,6 +433,7 @@ MediaControls.prototype.onMediaDuration_ = function() {
sliderContainer.classList.add('readonly');
var valueToString = function(value) {
+ var duration = this.media_ ? this.media_.duration : 0;
return MediaControls.formatTime_(this.media_.duration * value);
}.bind(this);
« no previous file with comments | « ui/file_manager/video_player/js/cast/media_manager.js ('k') | ui/file_manager/video_player/js/video_player.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698