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
bf3cf7b6
authored
2014-03-22 14:58:23 -0400
by
Gary Katsevman
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
code review comments
1 parent
b2f8fdc9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
34 deletions
src/videojs-hls.js
src/videojs-hls.js
View file @
bf3cf7b
...
...
@@ -32,7 +32,7 @@ videojs.hls = {
var
pluginOption
s
,
setting
s
,
// the desired length of video to maintain in the buffer, in seconds
goalBufferLength
=
5
,
...
...
@@ -129,7 +129,7 @@ var
if
(
responseType
)
{
request
.
responseType
=
responseType
;
}
if
(
pluginOption
s
.
withCredentials
)
{
if
(
setting
s
.
withCredentials
)
{
request
.
withCredentials
=
true
;
}
...
...
@@ -318,7 +318,7 @@ var
return
;
}
pluginOptions
=
options
||
{}
;
settings
=
videojs
.
util
.
mergeOptions
({},
options
)
;
srcUrl
=
(
function
()
{
var
...
...
@@ -658,42 +658,42 @@ var
// try moving on to the next segment
player
.
hls
.
mediaIndex
++
;
return
;
}
else
{
// stop processing if the request was aborted
if
(
!
this
.
response
)
{
return
;
}
}
// calculate the download bandwidth
player
.
hls
.
segmentXhrTime
=
(
+
new
Date
())
-
startTime
;
player
.
hls
.
bandwidth
=
(
this
.
response
.
byteLength
/
player
.
hls
.
segmentXhrTime
)
*
8
*
1000
;
// transmux the segment data from MP2T to FLV
segmentParser
.
parseSegmentBinaryData
(
new
Uint8Array
(
this
.
response
));
segmentParser
.
flushTags
();
// if we're refilling the buffer after a seek, scan through the muxed
// FLV tags until we find the one that is closest to the desired
// playback time
if
(
offset
!==
undefined
&&
typeof
offset
===
"number"
)
{
while
(
segmentParser
.
getTags
()[
0
].
pts
<
offset
)
{
segmentParser
.
getNextTag
();
}
}
// stop processing if the request was aborted
if
(
!
this
.
response
)
{
return
;
}
while
(
segmentParser
.
tagsAvailable
())
{
// queue up the bytes to be appended to the SourceBuffer
// the queue gives control back to the browser between tags
// so that large segments don't cause a "hiccup" in playback
tags
.
push
(
segmentParser
.
getNextTag
().
bytes
);
}
// calculate the download bandwidth
player
.
hls
.
segmentXhrTime
=
(
+
new
Date
())
-
startTime
;
player
.
hls
.
bandwidth
=
(
this
.
response
.
byteLength
/
player
.
hls
.
segmentXhrTime
)
*
8
*
1000
;
player
.
hls
.
mediaIndex
++
;
// transmux the segment data from MP2T to FLV
segmentParser
.
parseSegmentBinaryData
(
new
Uint8Array
(
this
.
response
));
segmentParser
.
flushTags
();
// figure out what stream the next segment should be downloaded from
// with the updated bandwidth information
updateCurrentPlaylist
();
// if we're refilling the buffer after a seek, scan through the muxed
// FLV tags until we find the one that is closest to the desired
// playback time
if
(
offset
!==
undefined
&&
typeof
offset
===
"number"
)
{
while
(
segmentParser
.
getTags
()[
0
].
pts
<
offset
)
{
segmentParser
.
getNextTag
();
}
}
while
(
segmentParser
.
tagsAvailable
())
{
// queue up the bytes to be appended to the SourceBuffer
// the queue gives control back to the browser between tags
// so that large segments don't cause a "hiccup" in playback
tags
.
push
(
segmentParser
.
getNextTag
().
bytes
);
}
player
.
hls
.
mediaIndex
++
;
// figure out what stream the next segment should be downloaded from
// with the updated bandwidth information
updateCurrentPlaylist
();
});
};
...
...
Please
register
or
sign in
to post a comment