Skip to content

Commit

Permalink
Add buffering events.
Browse files Browse the repository at this point in the history
Closes #25.

Change-Id: I0acac7195de6ddfc1386fa9334b0c2e278389a04
  • Loading branch information
joeyparrish committed Feb 24, 2015
1 parent a62f3bb commit 1a99082
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/player/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,23 @@ goog.require('shaka.util.Uint8ArrayUtils');
*/


/**
* @event shaka.player.Player.BufferingEvent
* @description Fired when the player's buffering state changes.
* @property {string} type 'bufferingStart' or 'bufferingEnd'
* @export
*/



/**
* Creates a Player.
*
* @param {!HTMLVideoElement} video The video element.
*
* @fires shaka.media.Stream.AdaptationEvent
* @fires shaka.player.Player.BufferingEvent
* @fires shaka.player.Player.ErrorEvent
* @fires shaka.dash.DashStream.AdaptationEvent
*
* @constructor
* @extends {shaka.util.FakeEventTarget}
Expand Down Expand Up @@ -1191,6 +1200,7 @@ shaka.player.Player.prototype.onWatchdogTimer_ = function() {
this.stats_.logBufferingEvent();
shaka.timer.begin('buffering');
shaka.log.debug('Buffering...');
this.dispatchEvent(shaka.util.FakeEvent.create({type: 'bufferingStart'}));
}
} else {
var resumeThreshold = this.videoSource_.getResumeThreshold();
Expand All @@ -1200,6 +1210,7 @@ shaka.player.Player.prototype.onWatchdogTimer_ = function() {
shaka.timer.end('buffering');
this.stats_.logBufferingTime(shaka.timer.get('buffering'));
this.buffering_ = false;
this.dispatchEvent(shaka.util.FakeEvent.create({type: 'bufferingEnd'}));
this.video_.play();
}
}
Expand Down

0 comments on commit 1a99082

Please sign in to comment.