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
17f9278f
authored
2014-10-30 16:20:24 -0400
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #180 from videojs/dont-downshift
Don't downshift in smart shifting.
2 parents
4b0e7317
35f858f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
7 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
17f9278
...
...
@@ -109,7 +109,7 @@ videojs.Hls.prototype.handleSourceOpen = function() {
this
.
playlists
=
new
videojs
.
Hls
.
PlaylistLoader
(
this
.
src_
,
settings
.
withCredentials
);
this
.
playlists
.
on
(
'loadedmetadata'
,
videojs
.
bind
(
this
,
function
()
{
var
selectedPlaylist
,
loaderHandler
,
newBitrate
,
segmentDuration
,
var
selectedPlaylist
,
loaderHandler
,
oldBitrate
,
newBitrate
,
segmentDuration
,
segmentDlTime
,
setupEvents
,
threshold
;
setupEvents
=
function
()
{
...
...
@@ -127,8 +127,10 @@ videojs.Hls.prototype.handleSourceOpen = function() {
oldMediaPlaylist
=
this
.
playlists
.
media
();
this
.
bandwidth
=
this
.
playlists
.
bandwidth
;
selectedPlaylist
=
this
.
selectPlaylist
();
oldBitrate
=
oldMediaPlaylist
.
attributes
&&
oldMediaPlaylist
.
attributes
.
BANDWIDTH
||
0
;
newBitrate
=
selectedPlaylist
.
attributes
&&
selectedPlaylist
.
attributes
.
BANDWIDTH
;
selectedPlaylist
.
attributes
.
BANDWIDTH
||
0
;
segmentDuration
=
oldMediaPlaylist
.
segments
&&
oldMediaPlaylist
.
segments
[
this
.
mediaIndex
].
duration
||
oldMediaPlaylist
.
targetDuration
;
...
...
@@ -143,7 +145,7 @@ videojs.Hls.prototype.handleSourceOpen = function() {
// request which is a somewhat small file.
threshold
=
10
;
if
(
segmentDlTime
<=
threshold
)
{
if
(
newBitrate
>
oldBitrate
&&
segmentDlTime
<=
threshold
)
{
this
.
playlists
.
media
(
selectedPlaylist
);
loaderHandler
=
videojs
.
bind
(
this
,
function
()
{
setupEvents
.
call
(
this
);
...
...
test/videojs-hls_test.js
View file @
17f9278
...
...
@@ -368,7 +368,7 @@ test('downloads media playlists after loading the master', function() {
'first segment requested'
);
});
test
(
'
downloads a second media playlist before playback, if
bandwidth is high'
,
function
()
{
test
(
'
upshift if initial
bandwidth is high'
,
function
()
{
player
.
src
({
src
:
'manifest/master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
...
...
@@ -378,11 +378,12 @@ test('downloads a second media playlist before playback, if bandwidth is high',
standardXHRResponse
(
requests
[
0
]);
player
.
hls
.
playlists
.
setBandwidth
=
function
()
{
player
.
hls
.
playlists
.
bandwidth
=
100000
;
player
.
hls
.
playlists
.
bandwidth
=
100000
0000
;
};
standardXHRResponse
(
requests
[
1
]);
standardXHRResponse
(
requests
[
2
]);
standardXHRResponse
(
requests
[
3
]);
strictEqual
(
requests
[
0
].
url
,
'manifest/master.m3u8'
,
'master playlist requested'
);
...
...
@@ -394,12 +395,41 @@ test('downloads a second media playlist before playback, if bandwidth is high',
strictEqual
(
requests
[
2
].
url
,
window
.
location
.
origin
+
window
.
location
.
pathname
.
split
(
'/'
).
slice
(
0
,
-
1
).
join
(
'/'
)
+
'/manifest/media
1
.m3u8'
,
'/manifest/media
3
.m3u8'
,
'media playlist requested'
);
strictEqual
(
requests
[
3
].
url
,
window
.
location
.
origin
+
window
.
location
.
pathname
.
split
(
'/'
).
slice
(
0
,
-
1
).
join
(
'/'
)
+
'/manifest/media1-00001.ts'
,
'/manifest/media3-00001.ts'
,
'first segment requested'
);
});
test
(
'dont downshift if bandwidth is low'
,
function
()
{
player
.
src
({
src
:
'manifest/master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
standardXHRResponse
(
requests
[
0
]);
player
.
hls
.
playlists
.
setBandwidth
=
function
()
{
player
.
hls
.
playlists
.
bandwidth
=
100
;
};
standardXHRResponse
(
requests
[
1
]);
standardXHRResponse
(
requests
[
2
]);
strictEqual
(
requests
[
0
].
url
,
'manifest/master.m3u8'
,
'master playlist requested'
);
strictEqual
(
requests
[
1
].
url
,
window
.
location
.
origin
+
window
.
location
.
pathname
.
split
(
'/'
).
slice
(
0
,
-
1
).
join
(
'/'
)
+
'/manifest/media.m3u8'
,
'media playlist requested'
);
strictEqual
(
requests
[
2
].
url
,
window
.
location
.
origin
+
window
.
location
.
pathname
.
split
(
'/'
).
slice
(
0
,
-
1
).
join
(
'/'
)
+
'/manifest/media-00001.ts'
,
'first segment requested'
);
});
...
...
Please
register
or
sign in
to post a comment