Commit b27b2bd2 authored by yoshiki's avatar yoshiki Committed by Commit bot

Support 'loop' atribute on fake video element for casting

BUG=413006
TEST=manually tested

Review URL: https://codereview.chromium.org/563253002

Cr-Commit-Position: refs/heads/master@{#294761}
parent b5e408e7
......@@ -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;
......@@ -192,6 +193,17 @@ CastVideoElement.prototype = {
// Do nothing.
},
/**
* 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_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment