diff --git a/src/videojs-hls.js b/src/videojs-hls.js index 33b4e1795..58bbcfd35 100644 --- a/src/videojs-hls.js +++ b/src/videojs-hls.js @@ -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([]); } diff --git a/test/videojs-hls_test.js b/test/videojs-hls_test.js index 72ed6184b..5d37589e0 100644 --- a/test/videojs-hls_test.js +++ b/test/videojs-hls_test.js @@ -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');