Skip to content

Commit

Permalink
I set preload to auto just before playing the video (fixes MailOnline#41
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sithmel committed Sep 15, 2015
1 parent 629feb3 commit 38309a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions demo/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ dom.onReady(function() {
}

function createVideoEl(container, cb) {
var videoTag = '<video class="video-js vjs-default-skin" controls preload="auto" poster="http://video-js.zencoder.com/oceans-clip.png" >' +
var videoTag = '<video class="video-js vjs-default-skin" controls preload="none" poster="http://video-js.zencoder.com/oceans-clip.png" >' +
'<source src="http://video-js.zencoder.com/oceans-clip.mp4" type="video/mp4"/>' +
'<source src="http://video-js.zencoder.com/oceans-clip.webm" type="video/webm"/>' +
'<source src="http://video-js.zencoder.com/oceans-clip.ogv" type="video/ogg"/>' +
Expand All @@ -174,4 +174,4 @@ dom.onReady(function() {
}, 0);
}
}
});
});
2 changes: 1 addition & 1 deletion src/ads/vast/client/VASTIntegrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ VASTIntegrator.prototype._addClickThrough = function addClickThrough(mediaFile,
VASTIntegrator.prototype._playSelectedAd = function playSelectedAd(source, response, callback) {
var player = this.player;

player.preload("auto"); //without preload=auto the durationchange event is never fired
player.src(source);

playerUtils.once(player, ['durationchange', 'error', 'vast.adsCancel'], function (evt) {
Expand Down Expand Up @@ -321,4 +322,3 @@ VASTIntegrator.prototype._playSelectedAd = function playSelectedAd(source, respo
VASTIntegrator.prototype._trackError = function trackError(error, response) {
vastUtil.track(response.errorURLMacros, {ERRORCODE: error.code || 900});
};

10 changes: 10 additions & 0 deletions test/ads/vast/client/VASTIntegrator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ describe("VASTIntegrator", function () {
assertError(callback, 'On VASTIntegrator, missing required VASTResponse');
});

it("must set preload to auto", function () {
// without preload=auto the durationchange event is never fired
var response = new VASTResponse();
var mediaFile = createMediaFile('http://foo.video.url.mp4', 'video/mp4');
response._addMediaFiles([mediaFile]);
var adUnit = vastIntegrator.playAd(response, noop);
this.clock.tick(1); // FF fail to set preload if there isn't at least an instruction in the middle
assert.equal(player.preload(), "auto");
});

it("must play the ad using the response", function () {
var response = new VASTResponse();

Expand Down

0 comments on commit 38309a6

Please sign in to comment.