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
499cf4b3
authored
2014-01-06 12:41:58 -0800
by
Tom Johnson
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
duration update moved to parser. fix for broken tests.
1 parent
f7098468
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
src/m3u8/m3u8-parser.js
src/videojs-hls.js
src/m3u8/m3u8-parser.js
View file @
499cf4b
...
...
@@ -284,8 +284,7 @@
// the manifest is empty until the parse stream begins delivering data
this
.
manifest
=
{
allowCache
:
true
,
totalDuration
:
0
allowCache
:
true
};
// update the manifest with the m3u8 entry from the parse stream
...
...
@@ -373,6 +372,17 @@
return
;
}
this
.
manifest
.
targetDuration
=
entry
.
duration
;
},
'endlist'
:
function
()
{
var
calculatedDuration
=
0
;
for
(
var
i
=
0
;
i
<
this
.
manifest
.
segments
.
length
;
i
++
)
{
if
(
this
.
manifest
.
segments
[
i
].
duration
)
{
calculatedDuration
+=
this
.
manifest
.
segments
[
i
].
duration
;
}
else
if
(
this
.
manifest
.
targetDuration
)
{
calculatedDuration
+=
this
.
manifest
.
targetDuration
;
}
}
this
.
trigger
(
'durationUpdate'
,
parseInt
(
calculatedDuration
));
}
})[
entry
.
tagType
]
||
noop
).
call
(
self
);
},
...
...
src/videojs-hls.js
View file @
499cf4b
...
...
@@ -28,7 +28,7 @@ var
segmentXhr
,
fillBuffer
,
on
LoadedManifest
,
on
DurationUpdate
,
selectPlaylist
;
extname
=
(
/
[^
#?
]
*
(?:\/[^
#?
]
*
\.([^
#?
]
*
))
/
).
exec
(
player
.
currentSrc
());
...
...
@@ -67,18 +67,8 @@ var
player
.
hls
.
currentMediaIndex
=
0
;
};
onLoadedManifest
=
function
()
{
if
(
player
.
hls
.
manifest
.
totalDuration
===
0
)
{
for
(
var
i
in
player
.
hls
.
manifest
.
segments
)
{
var
currentSegment
=
player
.
hls
.
manifest
.
segments
[
i
];
currentSegment
.
timeRange
=
{};
currentSegment
.
timeRange
.
start
=
player
.
hls
.
manifest
.
totalDuration
;
currentSegment
.
timeRange
.
end
=
currentSegment
.
timeRange
.
start
+
currentSegment
.
duration
;
player
.
hls
.
manifest
.
totalDuration
+=
currentSegment
.
duration
;
}
}
player
.
duration
(
player
.
hls
.
manifest
.
totalDuration
);
onDurationUpdate
=
function
(
value
)
{
player
.
duration
(
value
);
};
/**
...
...
@@ -159,8 +149,7 @@ var
};
player
.
on
(
'loadedmetadata'
,
fillBuffer
);
player
.
on
(
'timeupdate'
,
fillBuffer
);
player
.
on
(
'loadedmanifest'
,
onLoadedManifest
);
// download and process the manifest
(
function
()
{
var
xhr
=
new
window
.
XMLHttpRequest
();
...
...
@@ -171,6 +160,7 @@ var
if
(
xhr
.
readyState
===
4
)
{
// readystate DONE
parser
=
new
videojs
.
m3u8
.
Parser
();
parser
.
on
(
'durationUpdate'
,
onDurationUpdate
);
parser
.
push
(
xhr
.
responseText
);
player
.
hls
.
manifest
=
parser
.
manifest
;
...
...
Please
register
or
sign in
to post a comment