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
de317697
authored
2014-10-27 14:31:07 -0400
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #177 from videojs/cancelXhrs
Cancel xhrs
2 parents
180f73e0
b416adc6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
15 deletions
src/videojs-hls.js
src/videojs-hls.js
View file @
de31769
...
...
@@ -138,8 +138,7 @@ videojs.Hls.prototype.handleSourceOpen = function() {
this
.
playlists
.
on
(
'mediachange'
,
videojs
.
bind
(
this
,
function
()
{
// abort outstanding key requests and check if new keys need to be retrieved
if
(
keyXhr
)
{
keyXhr
.
abort
();
keyXhr
=
null
;
this
.
cancelKeyXhr
();
this
.
fetchKeys
(
this
.
playlists
.
media
(),
this
.
mediaIndex
);
}
...
...
@@ -195,17 +194,12 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) {
this
.
sourceBuffer
.
abort
();
// cancel outstanding requests and buffer appends
if
(
this
.
segmentXhr_
)
{
this
.
segmentXhr_
.
onreadystatechange
=
null
;
this
.
segmentXhr_
.
abort
();
this
.
segmentXhr_
=
null
;
}
this
.
cancelSegmentXhr
();
// fetch new encryption keys, if necessary
if
(
keyXhr
)
{
keyXhr
.
aborted
=
true
;
keyXhr
.
abort
();
keyXhr
=
null
;
this
.
cancelKeyXhr
();
this
.
fetchKeys
(
this
.
playlists
.
media
(),
this
.
mediaIndex
);
}
...
...
@@ -244,18 +238,28 @@ videojs.Hls.prototype.updateDuration = function(playlist) {
* state suitable for switching to a different video.
*/
videojs
.
Hls
.
prototype
.
resetSrc_
=
function
()
{
if
(
this
.
segmentXhr_
)
{
this
.
segmentXhr_
.
onreadystatechange
=
null
;
this
.
segmentXhr_
.
abort
();
this
.
segmentXhr_
=
null
;
this
.
cancelSegmentXhr
();
this
.
cancelKeyXhr
();
if
(
this
.
sourceBuffer
)
{
this
.
sourceBuffer
.
abort
();
}
};
videojs
.
Hls
.
prototype
.
cancelKeyXhr
=
function
()
{
if
(
keyXhr
)
{
keyXhr
.
onreadystatechange
=
null
;
keyXhr
.
abort
();
keyXhr
=
null
;
}
if
(
this
.
sourceBuffer
)
{
this
.
sourceBuffer
.
abort
();
};
videojs
.
Hls
.
prototype
.
cancelSegmentXhr
=
function
()
{
if
(
this
.
segmentXhr_
)
{
// Prevent error handler from running.
this
.
segmentXhr_
.
onreadystatechange
=
null
;
this
.
segmentXhr_
.
abort
();
this
.
segmentXhr_
=
null
;
}
};
...
...
Please
register
or
sign in
to post a comment