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
c51f8a1b
authored
2015-03-18 12:50:31 -0400
by
bc-bbay
Committed by
Brandon Bay
2015-03-20 13:02:08 -0400
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Updates for unit tests
1 parent
be19a03e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
c51f8a1
...
...
@@ -248,6 +248,10 @@ videojs.Hls.prototype.src = function(src) {
the current time to go along with it.
*/
videojs
.
Hls
.
getMediaIndexForLive
=
function
(
selectedPlaylist
)
{
if
(
!
selectedPlaylist
.
segments
)
{
return
0
;
}
var
tailIterator
=
selectedPlaylist
.
segments
.
length
,
tailDuration
=
0
,
targetTail
=
(
selectedPlaylist
.
targetDuration
||
10
)
*
3
;
...
...
@@ -287,7 +291,7 @@ videojs.Hls.prototype.play = function() {
this
.
mediaIndex
=
0
;
}
if
(
this
.
playlists
.
media
()
&&
!
this
.
player
_
.
hasClass
(
'vjs-has-started'
))
{
if
(
this
.
playlists
.
media
()
&&
!
this
.
player
()
.
hasClass
(
'vjs-has-started'
))
{
this
.
mediaIndex
=
videojs
.
Hls
.
getMediaIndexForLive
(
this
.
playlists
.
media
());
this
.
setCurrentTime
(
this
.
getCurrentTimeByMediaIndex
(
this
.
playlists
.
media
(),
this
.
mediaIndex
));
}
...
...
test/videojs-hls_test.js
View file @
c51f8a1
...
...
@@ -1259,9 +1259,13 @@ test('live playlist starts with correct currentTime value', function() {
standardXHRResponse
(
requests
[
0
]);
player
.
hls
.
playlists
.
trigger
(
'loadedmetadata'
);
player
.
hasClass
=
function
(
classname
)
{
return
player
.
el
().
classList
.
contains
(
classname
);
}
player
.
hls
.
play
();
strictEqual
(
player
.
currentTime
(),
6
0
,
'currentTime is updated at playback'
);
strictEqual
(
player
.
currentTime
(),
7
0
,
'currentTime is updated at playback'
);
});
test
(
'mediaIndex is zero before the first segment loads'
,
function
()
{
...
...
@@ -1735,6 +1739,11 @@ test('calling play() at the end of a video resets the media index', function() {
player
.
hls
.
ended
=
function
()
{
return
true
;
};
player
.
hasClass
=
function
(
classname
)
{
return
player
.
el
().
classList
.
contains
(
classname
);
}
player
.
play
();
strictEqual
(
player
.
hls
.
mediaIndex
,
0
,
'index is 1 after the first segment'
);
});
...
...
Please
register
or
sign in
to post a comment