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
1639b663
authored
2014-04-07 09:45:15 -0700
by
Tom Johnson
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add loadedmanifest handler for duration determination
1 parent
72b55580
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
10 deletions
src/videojs-hls.js
src/videojs-hls.js
View file @
1639b66
...
...
@@ -207,9 +207,10 @@ var
i
,
segment
;
if
(
!
playlist
.
segments
)
{
if
(
!
playlist
||
!
playlist
.
segments
)
{
return
0
;
}
i
=
playlist
.
segments
.
length
;
// if present, use the duration specified in the playlist
...
...
@@ -292,7 +293,8 @@ var
segmentXhr
,
loadedPlaylist
,
fillBuffer
,
updateCurrentPlaylist
;
updateCurrentPlaylist
,
updateDuration
;
// if the video element supports HLS natively, do nothing
if
(
videojs
.
hls
.
supportsNativeHls
)
{
...
...
@@ -366,6 +368,10 @@ var
return
1
;
// HAVE_METADATA
};
player
.
on
(
'loadedmanifest'
,
function
()
{
updateDuration
();
});
player
.
on
(
'seeking'
,
function
()
{
var
currentTime
=
player
.
currentTime
();
player
.
hls
.
mediaIndex
=
getMediaIndexByTime
(
player
.
hls
.
media
,
currentTime
);
...
...
@@ -381,6 +387,20 @@ var
});
/**
* Update the player duration
*/
updateDuration
=
function
()
{
// update the duration
player
.
duration
(
totalDuration
(
player
.
hls
.
media
));
// tell the flash tech of the new duration
if
(
player
.
el
().
querySelector
(
'.vjs-tech'
).
id
===
'video_flash_api'
)
{
player
.
el
().
querySelector
(
'.vjs-tech'
).
vjs_setProperty
(
'duration'
,
player
.
duration
());
}
// manually fire the duration change
player
.
trigger
(
'durationchange'
);
};
/**
* Determine whether the current media playlist should be changed
* and trigger a switch if necessary. If a sufficiently fresh
* version of the target playlist is available, the switch will take
...
...
@@ -406,14 +426,7 @@ var
playlist
);
player
.
hls
.
media
=
playlist
;
// update the duration
player
.
duration
(
totalDuration
(
player
.
hls
.
media
));
// tell the flash tech of the new duration
if
(
player
.
el
().
querySelector
(
'.vjs-tech'
).
id
===
'video_flash_api'
)
{
player
.
el
().
querySelector
(
'.vjs-tech'
).
vjs_setProperty
(
'duration'
,
player
.
duration
());
}
// manually fire the duration change
player
.
trigger
(
'durationchange'
);
updateDuration
();
}
};
...
...
Please
register
or
sign in
to post a comment