From 3768a7a5ac325defe5be1eeda502793259cdc170 Mon Sep 17 00:00:00 2001 From: spiterikevin Date: Fri, 19 Feb 2016 17:22:42 -0800 Subject: [PATCH] postpone fragment delaying until just before sending xhr request --- src/streaming/FragmentLoader.js | 10 +++++++++- src/streaming/models/FragmentModel.js | 10 ---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/streaming/FragmentLoader.js b/src/streaming/FragmentLoader.js index eb637fca62..8dafdfebda 100644 --- a/src/streaming/FragmentLoader.js +++ b/src/streaming/FragmentLoader.js @@ -172,7 +172,15 @@ function FragmentLoader(config) { } }; - req.send(); + //Adds the ability to delay single fragment loading time to control buffer. + let now = new Date().getTime(); + if (now < request.delayLoadingTime) { + setTimeout(function () { + req.send(); + }, (request.delayLoadingTime - now) ); + } else { + req.send(); + } } function checkForExistence(request) { diff --git a/src/streaming/models/FragmentModel.js b/src/streaming/models/FragmentModel.js index 6a33628cb9..95a00fe39a 100644 --- a/src/streaming/models/FragmentModel.js +++ b/src/streaming/models/FragmentModel.js @@ -181,18 +181,8 @@ function FragmentModel(config) { } function executeRequest(request) { - var now = new Date().getTime(); - if (!request) return; - //Adds the ability to delay single fragment loading time to control buffer. - if (now < request.delayLoadingTime ) { - delayLoadingTimeout = setTimeout(function () { - executeRequest(request); - }, (request.delayLoadingTime - now) ); - return; - } - switch (request.action) { case FragmentRequest.ACTION_COMPLETE: // Stream has completed, execute the corresponding callback