14e6480c by David LaPalomento

Merge branch 'jsanford-bc-master'

Hand-merge for #256.
2 parents 1670a237 9ce3dc2c
......@@ -459,6 +459,10 @@ videojs.Hls.prototype.selectPlaylist = function () {
// sort variants by resolution
bandwidthPlaylists.sort(videojs.Hls.comparePlaylistResolution);
// forget our old variant from above, or we might choose that in high-bandwidth scenarios
// (this could be the lowest bitrate rendition as we go through all of them above)
variant = null;
// iterate through the bandwidth-filtered playlists and find
// best rendition by player dimension
while (i--) {
......@@ -485,7 +489,7 @@ videojs.Hls.prototype.selectPlaylist = function () {
} else if (variant.attributes.RESOLUTION.width < player.width() &&
variant.attributes.RESOLUTION.height < player.height()) {
// if we don't have an exact match, see if we have a good higher quality variant to use
if (oldvariant.attributes && oldvariant.attributes.RESOLUTION &&
if (oldvariant && oldvariant.attributes && oldvariant.attributes.RESOLUTION &&
oldvariant.attributes.RESOLUTION.width && oldvariant.attributes.RESOLUTION.height) {
resolutionPlusOne = oldvariant;
}
......
......@@ -852,6 +852,32 @@ test('selects the correct rendition by player dimensions', function() {
});
test('selects the highest bitrate playlist when the player dimensions are ' +
'larger than any of the variants', function() {
var playlist;
player.src({
src: 'manifest/master.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(player);
requests.shift().respond(200, null,
'#EXTM3U\n' +
'#EXT-X-STREAM-INF:BANDWIDTH=1000,RESOLUTION=2x1\n' +
'media.m3u8\n' +
'#EXT-X-STREAM-INF:BANDWIDTH=1,RESOLUTION=1x1\n' +
'media1.m3u8\n'); // master
standardXHRResponse(requests.shift()); // media
player.hls.bandwidth = 1e10;
player.width(1024);
player.height(768);
playlist = player.hls.selectPlaylist();
equal(playlist.attributes.BANDWIDTH,
1000,
'selected the highest bandwidth variant');
});
test('does not download the next segment if the buffer is full', function() {
var currentTime = 15;
......