Skip to content

Commit

Permalink
Merge pull request #103 from ooyala/pbw-3096
Browse files Browse the repository at this point in the history
Pbw 3096
  • Loading branch information
liushh committed Aug 27, 2015
2 parents 2ca5abf + b5dd27c commit e49bc3d
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {

this.mb.subscribe(OO.EVENTS.WILL_PAUSE_ADS, "customerUi", _.bind(this.onWillPauseAds, this));
this.mb.subscribe(OO.EVENTS.WILL_RESUME_ADS, "customerUi", _.bind(this.onWillResumeAds, this));
//since iPhone does not show discover
this.mb.subscribe(OO.EVENTS.REPORT_DISCOVERY_IMPRESSION, "customerUi", _.bind(this.onReportDiscoveryImpression, this));
if (OO.EVENTS.DISCOVERY_API) {
this.mb.subscribe(OO.EVENTS.DISCOVERY_API.RELATED_VIDEOS_FETCHED, "customerUi", _.bind(this.onRelatedVideosFetched, this));
}
}

this.mb.subscribe(OO.EVENTS.CLOSED_CAPTIONS_INFO_AVAILABLE, "customerUi", _.bind(this.onClosedCaptionsInfoAvailable, this));
this.mb.subscribe(OO.EVENTS.CLOSED_CAPTION_CUE_CHANGED, "customerUi", _.bind(this.onClosedCaptionCueChanged, this));
this.mb.subscribe(OO.EVENTS.VOLUME_CHANGED, "customerUi", _.bind(this.onVolumeChanged, this));
if (OO.EVENTS.DISCOVERY_API) {
this.mb.subscribe(OO.EVENTS.DISCOVERY_API.RELATED_VIDEOS_FETCHED, "customerUi", _.bind(this.onRelatedVideosFetched, this));
}
this.mb.subscribe(OO.EVENTS.FULLSCREEN_CHANGED, "customerUi", _.bind(this.onFullscreenChanged, this));
},

Expand Down Expand Up @@ -205,6 +203,7 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
this.state.screenToShow = SCREEN.START_SCREEN;
} else if (this.skin.props.skinConfig.pauseScreen.screenToShowOnPause === "discovery") {
console.log("Should display DISCOVERY_SCREEN on pause");
this.sendDiscoveryDisplayEvent("pauseScreen");
this.state.screenToShow = SCREEN.DISCOVERY_SCREEN;
} else if (this.skin.props.skinConfig.pauseScreen.screenToShowOnPause === "social") {
// Remove this comment once pause screen implemented
Expand All @@ -220,6 +219,7 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
onPlayed: function() {
if (this.skin.props.skinConfig.endScreen.screenToShowOnEnd === "discovery") {
console.log("Should display DISCOVERY_SCREEN on end");
this.sendDiscoveryDisplayEvent("endScreen");
this.state.screenToShow = SCREEN.DISCOVERY_SCREEN;
} else if (this.skin.props.skinConfig.endScreen.screenToShowOnEnd === "share") {
this.state.screenToShow = SCREEN.SHARE_SCREEN;
Expand All @@ -231,12 +231,6 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
this.renderSkin();
},

onReportDiscoveryImpression: function(event, discoveryData) {
console.log("onReportDiscoveryImpression is called");
this.state.discoveryData = discoveryData;
this.renderSkin();
},

onSeeked: function(event) {
this.state.seeking = false;
},
Expand Down Expand Up @@ -316,6 +310,7 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {

onRelatedVideosFetched: function(event, relatedVideos) {
console.log("onRelatedVideosFetched is called");
this.state.discoveryData = {relatedVideos: relatedVideos.videos};
this.state.upNextInfo.upNextData = relatedVideos.videos[0];
this.renderSkin();
},
Expand Down Expand Up @@ -367,6 +362,7 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
switch(this.state.playerState) {
case STATE.PLAYING:
this.togglePlayPause();
this.sendDiscoveryDisplayEvent("pauseScreen");
setTimeout(function() {
this.state.screenToShow = SCREEN.DISCOVERY_SCREEN;
this.state.playerState = STATE.PAUSE;
Expand All @@ -380,6 +376,7 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
this.state.screenToShow = SCREEN.PAUSE_SCREEN;
}
else {
this.sendDiscoveryDisplayEvent("pauseScreen");
this.state.screenToShow = SCREEN.DISCOVERY_SCREEN;
}
break;
Expand All @@ -388,6 +385,7 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
this.state.screenToShow = SCREEN.END_SCREEN;
}
else {
this.sendDiscoveryDisplayEvent("endScreen");
this.state.screenToShow = SCREEN.DISCOVERY_SCREEN;
}
break;
Expand Down Expand Up @@ -478,6 +476,14 @@ OO.plugin("Html5Skin", function (OO, _, $, W) {
this.mb.publish(OO.EVENTS.DISCOVERY_API.SEND_CLICK_EVENT, selectedContentData);
},

sendDiscoveryDisplayEvent: function(screen) {
var eventData = {
"relatedVideos" : this.state.discoveryData.relatedVideos,
"custom" : { "source" : screen}
};
this.mb.publish(OO.EVENTS.DISCOVERY_API.SEND_DISPLAY_EVENT, eventData);
},

setClosedCaptionsLanguage: function(){
var language = this.state.ccOptions.enabled ? this.state.ccOptions.language : "";
var mode = this.state.ccOptions.enabled ? "showing" : "disabled";
Expand Down

0 comments on commit e49bc3d

Please sign in to comment.