From fcf7a685eb9c4767fcfd5e884e7762ef7a29d226 Mon Sep 17 00:00:00 2001 From: Lanny McNie Date: Thu, 1 Jun 2017 13:44:47 -0600 Subject: [PATCH] A (unsuccessful) test to fully preload videos in Chrome. Didn't solve the issue. --- src/preloadjs/loaders/VideoLoader.js | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/preloadjs/loaders/VideoLoader.js b/src/preloadjs/loaders/VideoLoader.js index fb92573..5d3f34d 100644 --- a/src/preloadjs/loaders/VideoLoader.js +++ b/src/preloadjs/loaders/VideoLoader.js @@ -72,6 +72,40 @@ this.createjs = this.createjs || {}; return createjs.Elements.video(); }; + p._formatResult = function(loader) { + var tag = this.AbstractMediaLoader__formatResult(loader); + if (!this._preferXHR && Math.round(tag.buffered.end(0)) <= tag.duration) { + var fn = createjs.proxy(function() { + tag.pause(); + tag.muted = true; + }, this); + + // Force the tag to play + tag.addEventListener("timeupdate", fn, false); + tag.play(); + return this._formatVideo; // Asynchronous + } + return tag; + }; + + /** + * Monitor video buffer progress + * @method _checkTagProgress + * @param event + * @private + */ + p._formatVideo = function(successCallback, errorCallback) { + var tag = this.getTag(); + var fn = createjs.proxy(function() { + if (Math.round(tag.buffered.end(0)) >= tag.duration) { + this.removeEventListener("progress", fn); + successCallback(tag); + } + }, this); + tag.addEventListener("progress", fn, false); + }; + + // static methods /** * Determines if the loader can load a specific item. This loader can only load items that are of type