Skip to content

Commit

Permalink
Change the onSeeked event in the Director to the onSeeking, as it was…
Browse files Browse the repository at this point in the history
… meant to be, but there was some confusion. Add the seeking event in the VideoHTML5 class, as it was missing.
  • Loading branch information
aberthet-gpsw committed May 23, 2017
1 parent 4dfa6ab commit 46bee30
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/director/Director.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ FORGE.Director.prototype._sceneLoadCompleteHandler = function()
// React on loading/buffering event
this._viewer.story.scene.media.displayObject.onWaiting.add(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onStalled.add(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeked.add(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeking.add(this._waitingHandler, this);

// The director's cut begin again if video is looping
this._viewer.story.scene.media.displayObject.onEnded.add(this._endedHandler, this);
Expand Down Expand Up @@ -285,8 +285,9 @@ FORGE.Director.prototype._waitingHandler = function()
{
this._viewer.story.scene.media.displayObject.onWaiting.remove(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onStalled.remove(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeked.remove(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeking.remove(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onPlaying.add(this._playingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeked.add(this._playingHandler, this);
}
// for controllers
this._viewer.controllers.onControlStart.remove(this._controlStartHandler, this);
Expand Down Expand Up @@ -316,9 +317,10 @@ FORGE.Director.prototype._playingHandler = function()
if (this._viewer.story.scene.media.type === FORGE.MediaType.VIDEO)
{
this._viewer.story.scene.media.displayObject.onPlaying.remove(this._playingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeked.remove(this._playingHandler, this);
this._viewer.story.scene.media.displayObject.onWaiting.add(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onStalled.add(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeked.add(this._waitingHandler, this);
this._viewer.story.scene.media.displayObject.onSeeking.add(this._waitingHandler, this);
}
// for controllers
this._viewer.controllers.onControlStart.add(this._controlStartHandler, this);
Expand Down
46 changes: 46 additions & 0 deletions src/display/video/VideoHTML5.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ FORGE.VideoHTML5 = function(viewer, key, config, qualityMode, ambisonic)
*/
this._onVolumeChange = null;

/**
* On seeking event dispatcher.
* @name FORGE.VideoHTML5#_onSeeking
* @type {?FORGE.EventDispatcher}
* @private
*/
this._onSeeking = null;

/**
* On seeked event dispatcher.
* @name FORGE.VideoHTML5#_onSeeked
Expand Down Expand Up @@ -1623,6 +1631,7 @@ FORGE.VideoHTML5.prototype._installEvents = function(element)
element.addEventListener("pause", this._onEventBind, false);
element.addEventListener("timeupdate", this._onEventBind, false);
element.addEventListener("volumechange", this._onEventBind, false);
element.addEventListener("seeking", this._onEventBind, false);
element.addEventListener("seeked", this._onEventBind, false);
element.addEventListener("ended", this._onEventBind, false);
element.addEventListener("error", this._onEventBind, false);
Expand Down Expand Up @@ -1650,6 +1659,7 @@ FORGE.VideoHTML5.prototype._uninstallEvents = function(element)
element.removeEventListener("pause", this._onEventBind, false);
element.removeEventListener("timeupdate", this._onEventBind, false);
element.removeEventListener("volumechange", this._onEventBind, false);
element.removeEventListener("seeking", this._onEventBind, false);
element.removeEventListener("seeked", this._onEventBind, false);
element.removeEventListener("ended", this._onEventBind, false);
element.removeEventListener("error", this._onEventBind, false);
Expand Down Expand Up @@ -1775,6 +1785,16 @@ FORGE.VideoHTML5.prototype._onEventHandler = function(event)

break;

case "seeking":
this._canPlay = false;

if (this._onSeeking !== null)
{
this._onSeeking.dispatch(event);
}

break;

case "seeked":
this._canPlay = false;

Expand Down Expand Up @@ -2108,6 +2128,12 @@ FORGE.VideoHTML5.prototype.destroy = function()
this._onVolumeChange = null;
}

if (this._onSeeking !== null)
{
this._onSeeking.destroy();
this._onSeeking = null;
}

if (this._onSeeked !== null)
{
this._onSeeked.destroy();
Expand Down Expand Up @@ -2886,6 +2912,26 @@ Object.defineProperty(FORGE.VideoHTML5.prototype, "onVolumeChange",
}
});

/**
* Get the "onSeeking" event {@link FORGE.EventDispatcher} of the video.
* @name FORGE.VideoHTML5#onSeeking
* @readonly
* @type {FORGE.EventDispatcher}
*/
Object.defineProperty(FORGE.VideoHTML5.prototype, "onSeeking",
{
/** @this {FORGE.VideoHTML5} */
get: function()
{
if (this._onSeeking === null)
{
this._onSeeking = new FORGE.EventDispatcher(this);
}

return this._onSeeking;
}
});

/**
* Get the "onSeeked" event {@link FORGE.EventDispatcher} of the video.
* @name FORGE.VideoHTML5#onSeeked
Expand Down

0 comments on commit 46bee30

Please sign in to comment.