Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #580 from forbesjo/null-check-mediasource
Browse files Browse the repository at this point in the history
Added an extra null check for mediaSource
  • Loading branch information
imbcmdth committed Mar 4, 2016
2 parents 6a9433a + fe517c0 commit b12ba42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/videojs-hls.js
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ var filterBufferedRanges = function(predicate) {
// report a fully empty buffer until SourceBuffers have been created
// which is after a segment has been loaded and transmuxed.
if (!this.mediaSource ||
!this.mediaSource.mediaSource_ ||
!this.mediaSource.mediaSource_.sourceBuffers.length) {
return videojs.createTimeRanges([]);
}
Expand Down
7 changes: 7 additions & 0 deletions test/videojs-hls_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,13 @@ test('always returns an empty buffered region when there are no SourceBuffers',
// Simulate the condition with no source buffers
player.hls.mediaSource.mediaSource_.sourceBuffers = [];

equal(player.tech_.hls.findBufferedRange_().length,
0,
'empty TimeRanges returned');

// Simulate the condition with no media source
player.hls.mediaSource.mediaSource_ = undefined;

equal(player.tech_.hls.findBufferedRange_().length,
0,
'empty TimeRanges returned');
Expand Down

0 comments on commit b12ba42

Please sign in to comment.