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
7a9c64e1
authored
11 years ago
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #38 from videojs/basic-live
Flash Tech Fix for Live UI
2 parents
3e56b573
0997e337
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
12 deletions
.gitignore
src/videojs-hls.js
test/videojs-hls_test.js
.gitignore
View file @
7a9c64e
.DS_Store
dist/*
/node_modules/
*~
*.iml
...
...
This diff is collapsed.
Click to expand it.
src/videojs-hls.js
View file @
7a9c64e
...
...
@@ -204,13 +204,8 @@ var
totalDuration
=
function
(
playlist
)
{
var
duration
=
0
,
i
,
segment
;
if
(
!
playlist
.
segments
)
{
return
0
;
}
i
=
playlist
.
segments
.
length
;
segment
,
i
=
(
playlist
.
segments
||
[]).
length
;
// if present, use the duration specified in the playlist
if
(
playlist
.
totalDuration
)
{
...
...
@@ -292,7 +287,8 @@ var
segmentXhr
,
loadedPlaylist
,
fillBuffer
,
updateCurrentPlaylist
;
updateCurrentPlaylist
,
updateDuration
;
// if the video element supports HLS natively, do nothing
if
(
videojs
.
hls
.
supportsNativeHls
)
{
...
...
@@ -381,6 +377,22 @@ var
});
/**
* Update the player duration
*/
updateDuration
=
function
(
playlist
)
{
var
tech
;
// update the duration
player
.
duration
(
totalDuration
(
playlist
));
// tell the flash tech of the new duration
tech
=
player
.
el
().
querySelector
(
'.vjs-tech'
);
if
(
tech
.
vjs_setProperty
)
{
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,8 +418,7 @@ var
playlist
);
player
.
hls
.
media
=
playlist
;
// update the duration
player
.
duration
(
totalDuration
(
player
.
hls
.
media
));
updateDuration
(
player
.
hls
.
media
);
}
};
...
...
@@ -558,7 +569,7 @@ var
player
.
hls
.
media
=
player
.
hls
.
master
.
playlists
[
0
];
// update the duration
player
.
duration
(
totalDuration
(
parser
.
manifest
)
);
updateDuration
(
parser
.
manifest
);
// periodicaly check if the buffer needs to be refilled
player
.
on
(
'timeupdate'
,
fillBuffer
);
...
...
@@ -585,7 +596,7 @@ var
var
buffered
=
player
.
buffered
(),
bufferedTime
=
0
,
segment
=
player
.
hls
.
media
.
segments
[
player
.
hls
.
mediaIndex
]
,
segment
,
segmentUri
,
startTime
;
...
...
@@ -594,7 +605,13 @@ var
return
;
}
// if no segments are available, do nothing
if
(
!
player
.
hls
.
media
.
segments
)
{
return
;
}
// if the video has finished downloading, stop trying to buffer
segment
=
player
.
hls
.
media
.
segments
[
player
.
hls
.
mediaIndex
];
if
(
!
segment
)
{
return
;
}
...
...
This diff is collapsed.
Click to expand it.
test/videojs-hls_test.js
View file @
7a9c64e
...
...
@@ -1109,4 +1109,28 @@ test('only reloads the active media playlist', function() {
'refreshed the active playlist'
);
});
test
(
'does not break if the playlist has no segments'
,
function
()
{
window
.
XMLHttpRequest
=
function
()
{
this
.
open
=
function
()
{};
this
.
send
=
function
()
{
this
.
readyState
=
4
;
this
.
status
=
200
;
this
.
responseText
=
'#EXTM3U\n'
+
'#EXT-X-PLAYLIST-TYPE:VOD\n'
+
'#EXT-X-TARGETDURATION:10\n'
;
this
.
onreadystatechange
();
};
};
player
.
hls
(
'manifest/master.m3u8'
);
try
{
videojs
.
mediaSources
[
player
.
currentSrc
()].
trigger
({
type
:
'sourceopen'
});
}
catch
(
e
)
{
ok
(
false
,
'an error was thrown'
);
throw
e
;
}
ok
(
true
,
'no error was thrown'
);
});
})(
window
,
window
.
videojs
);
...
...
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to post a comment