code review comments
Showing
1 changed file
with
34 additions
and
34 deletions
... | @@ -32,7 +32,7 @@ videojs.hls = { | ... | @@ -32,7 +32,7 @@ videojs.hls = { |
32 | 32 | ||
33 | var | 33 | var |
34 | 34 | ||
35 | pluginOptions, | 35 | settings, |
36 | 36 | ||
37 | // the desired length of video to maintain in the buffer, in seconds | 37 | // the desired length of video to maintain in the buffer, in seconds |
38 | goalBufferLength = 5, | 38 | goalBufferLength = 5, |
... | @@ -129,7 +129,7 @@ var | ... | @@ -129,7 +129,7 @@ var |
129 | if (responseType) { | 129 | if (responseType) { |
130 | request.responseType = responseType; | 130 | request.responseType = responseType; |
131 | } | 131 | } |
132 | if (pluginOptions.withCredentials) { | 132 | if (settings.withCredentials) { |
133 | request.withCredentials = true; | 133 | request.withCredentials = true; |
134 | } | 134 | } |
135 | 135 | ||
... | @@ -318,7 +318,7 @@ var | ... | @@ -318,7 +318,7 @@ var |
318 | return; | 318 | return; |
319 | } | 319 | } |
320 | 320 | ||
321 | pluginOptions = options || {}; | 321 | settings = videojs.util.mergeOptions({}, options); |
322 | 322 | ||
323 | srcUrl = (function() { | 323 | srcUrl = (function() { |
324 | var | 324 | var |
... | @@ -658,42 +658,42 @@ var | ... | @@ -658,42 +658,42 @@ var |
658 | // try moving on to the next segment | 658 | // try moving on to the next segment |
659 | player.hls.mediaIndex++; | 659 | player.hls.mediaIndex++; |
660 | return; | 660 | return; |
661 | } else { | 661 | } |
662 | // stop processing if the request was aborted | ||
663 | if (!this.response) { | ||
664 | return; | ||
665 | } | ||
666 | 662 | ||
667 | // calculate the download bandwidth | 663 | // stop processing if the request was aborted |
668 | player.hls.segmentXhrTime = (+new Date()) - startTime; | 664 | if (!this.response) { |
669 | player.hls.bandwidth = (this.response.byteLength / player.hls.segmentXhrTime) * 8 * 1000; | 665 | return; |
670 | 666 | } | |
671 | // transmux the segment data from MP2T to FLV | ||
672 | segmentParser.parseSegmentBinaryData(new Uint8Array(this.response)); | ||
673 | segmentParser.flushTags(); | ||
674 | |||
675 | // if we're refilling the buffer after a seek, scan through the muxed | ||
676 | // FLV tags until we find the one that is closest to the desired | ||
677 | // playback time | ||
678 | if (offset !== undefined && typeof offset === "number") { | ||
679 | while (segmentParser.getTags()[0].pts < offset) { | ||
680 | segmentParser.getNextTag(); | ||
681 | } | ||
682 | } | ||
683 | 667 | ||
684 | while (segmentParser.tagsAvailable()) { | 668 | // calculate the download bandwidth |
685 | // queue up the bytes to be appended to the SourceBuffer | 669 | player.hls.segmentXhrTime = (+new Date()) - startTime; |
686 | // the queue gives control back to the browser between tags | 670 | player.hls.bandwidth = (this.response.byteLength / player.hls.segmentXhrTime) * 8 * 1000; |
687 | // so that large segments don't cause a "hiccup" in playback | ||
688 | tags.push(segmentParser.getNextTag().bytes); | ||
689 | } | ||
690 | 671 | ||
691 | player.hls.mediaIndex++; | 672 | // transmux the segment data from MP2T to FLV |
673 | segmentParser.parseSegmentBinaryData(new Uint8Array(this.response)); | ||
674 | segmentParser.flushTags(); | ||
692 | 675 | ||
693 | // figure out what stream the next segment should be downloaded from | 676 | // if we're refilling the buffer after a seek, scan through the muxed |
694 | // with the updated bandwidth information | 677 | // FLV tags until we find the one that is closest to the desired |
695 | updateCurrentPlaylist(); | 678 | // playback time |
679 | if (offset !== undefined && typeof offset === "number") { | ||
680 | while (segmentParser.getTags()[0].pts < offset) { | ||
681 | segmentParser.getNextTag(); | ||
682 | } | ||
696 | } | 683 | } |
684 | |||
685 | while (segmentParser.tagsAvailable()) { | ||
686 | // queue up the bytes to be appended to the SourceBuffer | ||
687 | // the queue gives control back to the browser between tags | ||
688 | // so that large segments don't cause a "hiccup" in playback | ||
689 | tags.push(segmentParser.getNextTag().bytes); | ||
690 | } | ||
691 | |||
692 | player.hls.mediaIndex++; | ||
693 | |||
694 | // figure out what stream the next segment should be downloaded from | ||
695 | // with the updated bandwidth information | ||
696 | updateCurrentPlaylist(); | ||
697 | }); | 697 | }); |
698 | }; | 698 | }; |
699 | 699 | ... | ... |
-
Please register or sign in to post a comment