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
bd709446
authored
2014-09-22 15:59:28 -0400
by
Gary Katsevman
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add test and null segementXhr in dispose
1 parent
b4202427
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
bd70944
...
...
@@ -237,6 +237,7 @@ videojs.Hls.prototype.dispose = function() {
if
(
this
.
segmentXhr_
)
{
this
.
segmentXhr_
.
onreadystatechange
=
null
;
this
.
segmentXhr_
.
abort
();
this
.
segmentXhr_
=
null
;
}
if
(
keyXhr
)
{
keyXhr
.
onreadystatechange
=
null
;
...
...
test/videojs-hls_test.js
View file @
bd70944
...
...
@@ -710,6 +710,41 @@ test('cancels outstanding XHRs when seeking', function() {
strictEqual
(
requests
.
length
,
3
,
'opened new XHR'
);
});
test
(
'when outstanding XHRs are cancelled, they get aborted properly'
,
function
()
{
var
readystatechanges
=
0
;
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
++
;
};
// attempt to seek while the download is in progress
player
.
currentTime
(
12
);
ok
(
requests
[
1
].
aborted
,
'XHR aborted'
);
strictEqual
(
requests
.
length
,
3
,
'opened new XHR'
);
notEqual
(
player
.
hls
.
segmentXhr_
.
url
,
requests
[
1
].
url
,
'the segment xhr is nulled out'
);
strictEqual
(
readystatechanges
,
0
,
'onreadystatechange was not called'
);
});
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