d37dc706 by Gary Katsevman

Use getComputedStyle instead of player.width

When upswitching, we try to find the best resolution based on bandwidth
and based on the player dimensions. However, player.width will return
the set width value of the player (https://github.com/videojs/video.js/issues/2282) instead of the current value which means that in fullscreen we don't think we the player changes size and so we don't upswitch.
1 parent 0227bf64
...@@ -486,7 +486,9 @@ videojs.Hls.prototype.selectPlaylist = function () { ...@@ -486,7 +486,9 @@ videojs.Hls.prototype.selectPlaylist = function () {
486 oldvariant, 486 oldvariant,
487 bandwidthBestVariant, 487 bandwidthBestVariant,
488 resolutionPlusOne, 488 resolutionPlusOne,
489 resolutionBestVariant; 489 resolutionBestVariant,
490 playerWidth,
491 playerHeight;
490 492
491 sortedPlaylists.sort(videojs.Hls.comparePlaylistBandwidth); 493 sortedPlaylists.sort(videojs.Hls.comparePlaylistBandwidth);
492 494
...@@ -522,6 +524,9 @@ videojs.Hls.prototype.selectPlaylist = function () { ...@@ -522,6 +524,9 @@ videojs.Hls.prototype.selectPlaylist = function () {
522 // (this could be the lowest bitrate rendition as we go through all of them above) 524 // (this could be the lowest bitrate rendition as we go through all of them above)
523 variant = null; 525 variant = null;
524 526
527 playerWidth = parseInt(getComputedStyle(player.el()).width, 10);
528 playerHeight = parseInt(getComputedStyle(player.el()).height, 10);
529
525 // iterate through the bandwidth-filtered playlists and find 530 // iterate through the bandwidth-filtered playlists and find
526 // best rendition by player dimension 531 // best rendition by player dimension
527 while (i--) { 532 while (i--) {
...@@ -539,14 +544,14 @@ videojs.Hls.prototype.selectPlaylist = function () { ...@@ -539,14 +544,14 @@ videojs.Hls.prototype.selectPlaylist = function () {
539 544
540 // since the playlists are sorted, the first variant that has 545 // since the playlists are sorted, the first variant that has
541 // dimensions less than or equal to the player size is the best 546 // dimensions less than or equal to the player size is the best
542 if (variant.attributes.RESOLUTION.width === player.width() && 547 if (variant.attributes.RESOLUTION.width === playerWidth &&
543 variant.attributes.RESOLUTION.height === player.height()) { 548 variant.attributes.RESOLUTION.height === playerHeight) {
544 // if we have the exact resolution as the player use it 549 // if we have the exact resolution as the player use it
545 resolutionPlusOne = null; 550 resolutionPlusOne = null;
546 resolutionBestVariant = variant; 551 resolutionBestVariant = variant;
547 break; 552 break;
548 } else if (variant.attributes.RESOLUTION.width < player.width() && 553 } else if (variant.attributes.RESOLUTION.width < playerWidth &&
549 variant.attributes.RESOLUTION.height < player.height()) { 554 variant.attributes.RESOLUTION.height < playerHeight) {
550 // if we don't have an exact match, see if we have a good higher quality variant to use 555 // if we don't have an exact match, see if we have a good higher quality variant to use
551 if (oldvariant && oldvariant.attributes && oldvariant.attributes.RESOLUTION && 556 if (oldvariant && oldvariant.attributes && oldvariant.attributes.RESOLUTION &&
552 oldvariant.attributes.RESOLUTION.width && oldvariant.attributes.RESOLUTION.height) { 557 oldvariant.attributes.RESOLUTION.width && oldvariant.attributes.RESOLUTION.height) {
......