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

Unified Diff: ui/file_manager/video_player/js/cast/cast_video_element.js

Issue 563253002: Support 'loop' atribute on fake video element for casting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a JSdoc 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/video_player/js/cast/cast_video_element.js
diff --git a/ui/file_manager/video_player/js/cast/cast_video_element.js b/ui/file_manager/video_player/js/cast/cast_video_element.js
index d61396494257871783b63e6b36429d79415c1fe5..ccbc342f5dbb6f133fe92d3e5dff1b3d881ffd3e 100644
--- a/ui/file_manager/video_player/js/cast/cast_video_element.js
+++ b/ui/file_manager/video_player/js/cast/cast_video_element.js
@@ -36,6 +36,7 @@ function CastVideoElement(media, session) {
this.currentTime_ = null;
this.src_ = '';
this.volume_ = 100;
+ this.loop_ = false;
this.currentMediaPlayerState_ = null;
this.currentMediaCurrentTime_ = null;
this.currentMediaDuration_ = null;
@@ -193,6 +194,17 @@ CastVideoElement.prototype = {
},
/**
+ * Returns the flag if the video loops at end or not.
+ * @type {boolean}
+ */
+ get loop() {
+ return this.loop_;
+ },
+ set loop(value) {
+ this.loop_ = !!value;
+ },
+
+ /**
* Returns the error object if available.
* @type {?Object}
*/
@@ -408,6 +420,21 @@ CastVideoElement.prototype = {
return;
var media = this.castMedia_;
+ if (this.loop_ &&
+ media.idleReason === chrome.cast.media.IdleReason.FINISHED &&
+ !alive) {
+ // Resets the previous media silently.
+ this.castMedia_ = null;
+
+ // Replay the current media.
+ this.currentMediaPlayerState_ = chrome.cast.media.PlayerState.BUFFERING;
+ this.currentMediaCurrentTime_ = 0;
+ this.dispatchEvent(new Event('play'));
+ this.dispatchEvent(new Event('timeupdate'));
+ this.play();
+ return;
+ }
+
if (this.currentMediaPlayerState_ !== media.playerState) {
var oldPlayState = false;
var oldState = this.currentMediaPlayerState_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698