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
f658c6c0
authored
2016-02-16 13:52:26 -0500
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #551 from dmlap/null-check-computed-style
Avoid Firefox issue 548397
2 parents
1c31597b
c553bc5d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
4 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
f658c6c
...
...
@@ -17,6 +17,7 @@ var
// The amount of time to wait between checking the state of the buffer
bufferCheckInterval
=
500
,
safeGetComputedStyle
,
keyFailed
,
resolveUrl
;
...
...
@@ -683,6 +684,27 @@ videojs.HlsHandler.prototype.cancelSegmentXhr = function() {
};
/**
* Returns the CSS value for the specified property on an element
* using `getComputedStyle`. Firefox has a long-standing issue where
* getComputedStyle() may return null when running in an iframe with
* `display: none`.
* @see https://bugzilla.mozilla.org/show_bug.cgi?id=548397
*/
safeGetComputedStyle
=
function
(
el
,
property
)
{
var
result
;
if
(
!
el
)
{
return
''
;
}
result
=
getComputedStyle
(
el
);
if
(
!
result
)
{
return
''
;
}
return
result
[
property
];
};
/**
* Abort all outstanding work and cleanup.
*/
videojs
.
HlsHandler
.
prototype
.
dispose
=
function
()
{
...
...
@@ -760,8 +782,8 @@ videojs.HlsHandler.prototype.selectPlaylist = function () {
// (this could be the lowest bitrate rendition as we go through all of them above)
variant
=
null
;
width
=
parseInt
(
getComputedStyle
(
this
.
tech_
.
el
()).
width
,
10
);
height
=
parseInt
(
getComputedStyle
(
this
.
tech_
.
el
()).
height
,
10
);
width
=
parseInt
(
safeGetComputedStyle
(
this
.
tech_
.
el
(),
'width'
)
,
10
);
height
=
parseInt
(
safeGetComputedStyle
(
this
.
tech_
.
el
(),
'height'
)
,
10
);
// iterate through the bandwidth-filtered playlists and find
// best rendition by player dimension
...
...
test/videojs-hls_test.js
View file @
f658c6c
...
...
@@ -3079,12 +3079,12 @@ test('does not process update end until buffered value has been set', function()
src
:
'master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
origDrainBuffer
=
player
.
tech_
.
hls
.
drainBuffer
;
player
.
tech_
.
hls
.
drainBuffer
=
function
()
{
drainBufferCallCount
++
;
};
openMediaSource
(
player
);
standardXHRResponse
(
requests
.
shift
());
// master
standardXHRResponse
(
requests
.
shift
());
// media
...
...
@@ -3106,6 +3106,26 @@ test('does not process update end until buffered value has been set', function()
ok
(
!
player
.
tech_
.
hls
.
pendingSegment_
,
'pending segment cleared out'
);
});
// workaround https://bugzilla.mozilla.org/show_bug.cgi?id=548397
test
(
'selectPlaylist does not fail if getComputedStyle returns null'
,
function
()
{
var
oldGetComputedStyle
=
window
.
getComputedStyle
;
window
.
getComputedStyle
=
function
()
{
return
null
;
};
player
.
src
({
src
:
'master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
standardXHRResponse
(
requests
.
shift
());
// master
standardXHRResponse
(
requests
.
shift
());
// media
player
.
tech_
.
hls
.
selectPlaylist
();
ok
(
true
,
'should not throw'
);
window
.
getComputedStyle
=
oldGetComputedStyle
;
});
module
(
'Buffer Inspection'
);
test
(
'detects time range end-point changed by updates'
,
function
()
{
...
...
Please
register
or
sign in
to post a comment