Skip to content

Commit

Permalink
[PBW-5360] [PV4] Mid Rolls not working in DFP Mobile
Browse files Browse the repository at this point in the history
* Fixing infinite playing event loop that happens with API seek calls for HLS assets on iOS
* Updated unit tests
  • Loading branch information
mityaha authored and rchalooyala committed Jun 1, 2016
1 parent 0515467 commit db9896d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/js/main_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ require("../../../html5-common/js/utils/environment.js");
this.setClosedCaptions = _.bind(function(language, closedCaptions, params) {
//Remove and disable current captions before setting new ones.
$(_video).find('.' + TRACK_CLASS).remove();
this.setClosedCaptionsMode(OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED);
if (language == null) return;

var captionMode = (params && params.mode) || OO.CONSTANTS.CLOSED_CAPTIONS.SHOWING;
Expand Down Expand Up @@ -549,6 +548,7 @@ require("../../../html5-common/js/utils/environment.js");
}
}
} else if (!captions.inStream) {
this.setClosedCaptionsMode(OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED);
$(_video).append("<track class='" + TRACK_CLASS + "' kind='subtitles' label='" + captions.label + "' src='" + captions.src + "' srclang='" + captions.language + "' default>");
if (_video.textTracks && _video.textTracks[0]) {
_video.textTracks[0].mode = captionMode;
Expand Down
46 changes: 44 additions & 2 deletions tests/unit/main_html5/wrapper-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ describe('main_html5 wrapper tests', function () {
expect(element.src).to.eql("");
});

it('should set closed captions', function(){
it('should set external closed captions', function(){
OO.CONSTANTS = {
CLOSED_CAPTIONS: {
SHOWING: "showing",
Expand Down Expand Up @@ -431,14 +431,56 @@ describe('main_html5 wrapper tests', function () {
expect(element.children[0].getAttribute("srclang")).to.eql("en");
});

it('should remove closed captions if language is null', function(){
it('should set closed captions mode for in-stream captions', function(){
OO.CONSTANTS = {
CLOSED_CAPTIONS: {
SHOWING: "showing",
HIDDEN: "hidden",
DISABLED: "disabled"
}
};

element.textTracks = [{ mode: OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED, kind: "captions" }];
$(element).triggerHandler("playing");
expect(element.textTracks[0].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED);
wrapper.setClosedCaptions("CC", null, { mode: "showing" });
expect(element.textTracks[0].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.SHOWING);
});

it('should set both in-stream and external closed captions and switches between them', function(){
OO.CONSTANTS = {
CLOSED_CAPTIONS: {
SHOWING: "showing",
HIDDEN: "hidden",
DISABLED: "disabled"
}
};
var closedCaptions = {
closed_captions_vtt: {
en: {
name: "English",
url: "http://ooyala.com"
}
}
};

element.textTracks = [{ kind: "captions" }, { kind: "captions" }];
$(element).triggerHandler("playing"); // this adds in-stream captions

wrapper.setClosedCaptionsMode(OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED);
expect(element.textTracks[0].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED);
expect(element.textTracks[1].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED);

wrapper.setClosedCaptions("CC", null, {mode: OO.CONSTANTS.CLOSED_CAPTIONS.SHOWING});
expect(element.textTracks[0].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.SHOWING);
expect(element.textTracks[1].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.SHOWING);

wrapper.setClosedCaptions("en", closedCaptions, {mode: OO.CONSTANTS.CLOSED_CAPTIONS.HIDDEN}); // this adds external captions
expect(element.textTracks[0].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.HIDDEN);
expect(element.textTracks[1].mode).to.eql(OO.CONSTANTS.CLOSED_CAPTIONS.DISABLED);
});

it('should remove closed captions if language is null', function(){
var language = "en";
var closedCaptions = {
closed_captions_vtt: {
Expand Down

0 comments on commit db9896d

Please sign in to comment.