From bf3cf7b64925a4643d071e7449956bfbbee80800 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Sat, 22 Mar 2014 14:58:23 -0400 Subject: [PATCH] code review comments --- src/videojs-hls.js | 68 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/videojs-hls.js b/src/videojs-hls.js index 08617d06..2de73136 100644 --- a/src/videojs-hls.js +++ b/src/videojs-hls.js @@ -32,7 +32,7 @@ videojs.hls = { var - pluginOptions, + settings, // the desired length of video to maintain in the buffer, in seconds goalBufferLength = 5, @@ -129,7 +129,7 @@ var if (responseType) { request.responseType = responseType; } - if (pluginOptions.withCredentials) { + if (settings.withCredentials) { request.withCredentials = true; } @@ -318,7 +318,7 @@ var return; } - pluginOptions = options || {}; + settings = videojs.util.mergeOptions({}, options); srcUrl = (function() { var @@ -658,42 +658,42 @@ var // try moving on to the next segment player.hls.mediaIndex++; return; - } else { - // stop processing if the request was aborted - if (!this.response) { - return; - } + } - // calculate the download bandwidth - player.hls.segmentXhrTime = (+new Date()) - startTime; - player.hls.bandwidth = (this.response.byteLength / player.hls.segmentXhrTime) * 8 * 1000; - - // transmux the segment data from MP2T to FLV - segmentParser.parseSegmentBinaryData(new Uint8Array(this.response)); - segmentParser.flushTags(); - - // if we're refilling the buffer after a seek, scan through the muxed - // FLV tags until we find the one that is closest to the desired - // playback time - if (offset !== undefined && typeof offset === "number") { - while (segmentParser.getTags()[0].pts < offset) { - segmentParser.getNextTag(); - } - } + // stop processing if the request was aborted + if (!this.response) { + return; + } - while (segmentParser.tagsAvailable()) { - // queue up the bytes to be appended to the SourceBuffer - // the queue gives control back to the browser between tags - // so that large segments don't cause a "hiccup" in playback - tags.push(segmentParser.getNextTag().bytes); - } + // calculate the download bandwidth + player.hls.segmentXhrTime = (+new Date()) - startTime; + player.hls.bandwidth = (this.response.byteLength / player.hls.segmentXhrTime) * 8 * 1000; - player.hls.mediaIndex++; + // transmux the segment data from MP2T to FLV + segmentParser.parseSegmentBinaryData(new Uint8Array(this.response)); + segmentParser.flushTags(); - // figure out what stream the next segment should be downloaded from - // with the updated bandwidth information - updateCurrentPlaylist(); + // if we're refilling the buffer after a seek, scan through the muxed + // FLV tags until we find the one that is closest to the desired + // playback time + if (offset !== undefined && typeof offset === "number") { + while (segmentParser.getTags()[0].pts < offset) { + segmentParser.getNextTag(); + } } + + while (segmentParser.tagsAvailable()) { + // queue up the bytes to be appended to the SourceBuffer + // the queue gives control back to the browser between tags + // so that large segments don't cause a "hiccup" in playback + tags.push(segmentParser.getNextTag().bytes); + } + + player.hls.mediaIndex++; + + // figure out what stream the next segment should be downloaded from + // with the updated bandwidth information + updateCurrentPlaylist(); }); };