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
89601c9c
authored
2014-09-22 16:01:33 -0400
by
Gary Katsevman
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Remove event handlers in dispose.
Test that segmentXhr gets nulled out in dispose.
1 parent
bd709446
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
89601c9
...
...
@@ -234,6 +234,13 @@ videojs.Hls.prototype.updateDuration = function(playlist) {
* Abort all outstanding work and cleanup.
*/
videojs
.
Hls
.
prototype
.
dispose
=
function
()
{
var
player
=
this
.
player
();
// remove event handlers
player
.
off
(
'timeupdate'
,
this
.
fillBuffer
);
player
.
off
(
'timeupdate'
,
this
.
drainBuffer
);
player
.
off
(
'waiting'
,
this
.
drainBuffer
);
if
(
this
.
segmentXhr_
)
{
this
.
segmentXhr_
.
onreadystatechange
=
null
;
this
.
segmentXhr_
.
abort
();
...
...
test/videojs-hls_test.js
View file @
89601c9
...
...
@@ -745,6 +745,44 @@ test('when outstanding XHRs are cancelled, they get aborted properly', function(
strictEqual
(
readystatechanges
,
0
,
'onreadystatechange was not called'
);
});
test
(
'segmentXhr is properly nulled out when dispose is called'
,
function
()
{
var
readystatechanges
=
0
,
oldDispose
=
videojs
.
Flash
.
prototype
.
dispose
;
videojs
.
Flash
.
prototype
.
dispose
=
function
()
{};
player
.
src
({
src
:
'manifest/media.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
standardXHRResponse
(
requests
[
0
]);
player
.
hls
.
media
=
{
segments
:
[{
uri
:
'0.ts'
,
duration
:
10
},
{
uri
:
'1.ts'
,
duration
:
10
}]
};
// trigger a segment download request
player
.
trigger
(
'timeupdate'
);
player
.
hls
.
segmentXhr_
.
onreadystatechange
=
function
()
{
readystatechanges
++
;
};
player
.
hls
.
dispose
();
ok
(
requests
[
1
].
aborted
,
'XHR aborted'
);
strictEqual
(
requests
.
length
,
2
,
'did not open a new XHR'
);
equal
(
player
.
hls
.
segmentXhr_
,
null
,
'the segment xhr is nulled out'
);
strictEqual
(
readystatechanges
,
0
,
'onreadystatechange was not called'
);
videojs
.
Flash
.
prototype
.
dispose
=
oldDispose
;
});
test
(
'flushes the parser after each segment'
,
function
()
{
var
flushes
=
0
;
// mock out the segment parser
...
...
Please
register
or
sign in
to post a comment