Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
9c432427
authored
2015-06-26 12:32:37 -0400
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Use getComputedStyle for player dimensions when filtering variants. Closes #326
2 parents
c2e40eba
310d41f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
CHANGELOG.md
src/videojs-hls.js
CHANGELOG.md
View file @
9c43242
...
...
@@ -4,6 +4,7 @@ CHANGELOG
## HEAD (Unreleased)
*
@dmlap improved video duration calculation. (
[
view
](
https://github.com/videojs/videojs-contrib-hls/pull/321
)
)
*
Clamp seeks to the seekable range (
[
view
](
https://github.com/videojs/videojs-contrib-hls/pull/327
)
)
*
Use getComputedStyle for player dimensions when filtering variants (
[
view
](
https://github.com/videojs/videojs-contrib-hls/pull/326
)
)
--------------------
...
...
src/videojs-hls.js
View file @
9c43242
...
...
@@ -502,7 +502,9 @@ videojs.Hls.prototype.selectPlaylist = function () {
oldvariant
,
bandwidthBestVariant
,
resolutionPlusOne
,
resolutionBestVariant
;
resolutionBestVariant
,
playerWidth
,
playerHeight
;
sortedPlaylists
.
sort
(
videojs
.
Hls
.
comparePlaylistBandwidth
);
...
...
@@ -538,6 +540,9 @@ videojs.Hls.prototype.selectPlaylist = function () {
// (this could be the lowest bitrate rendition as we go through all of them above)
variant
=
null
;
playerWidth
=
parseInt
(
getComputedStyle
(
player
.
el
()).
width
,
10
);
playerHeight
=
parseInt
(
getComputedStyle
(
player
.
el
()).
height
,
10
);
// iterate through the bandwidth-filtered playlists and find
// best rendition by player dimension
while
(
i
--
)
{
...
...
@@ -555,14 +560,14 @@ videojs.Hls.prototype.selectPlaylist = function () {
// since the playlists are sorted, the first variant that has
// dimensions less than or equal to the player size is the best
if
(
variant
.
attributes
.
RESOLUTION
.
width
===
player
.
width
()
&&
variant
.
attributes
.
RESOLUTION
.
height
===
player
.
height
()
)
{
if
(
variant
.
attributes
.
RESOLUTION
.
width
===
player
Width
&&
variant
.
attributes
.
RESOLUTION
.
height
===
player
Height
)
{
// if we have the exact resolution as the player use it
resolutionPlusOne
=
null
;
resolutionBestVariant
=
variant
;
break
;
}
else
if
(
variant
.
attributes
.
RESOLUTION
.
width
<
player
.
width
()
&&
variant
.
attributes
.
RESOLUTION
.
height
<
player
.
height
()
)
{
}
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
&&
oldvariant
.
attributes
&&
oldvariant
.
attributes
.
RESOLUTION
&&
oldvariant
.
attributes
.
RESOLUTION
.
width
&&
oldvariant
.
attributes
.
RESOLUTION
.
height
)
{
...
...
Please
register
or
sign in
to post a comment