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
66510e67
authored
2015-02-08 17:56:13 -0500
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'stevemayhew-fix-keyurl'
2 parents
7436e467
731fd8d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
src/videojs-hls.js
test/videojs-hls_test.js
src/videojs-hls.js
View file @
66510e6
...
...
@@ -472,13 +472,20 @@ videojs.Hls.prototype.fillBuffer = function(offset) {
}
// resolve the segment URL relative to the playlist
segmentUri
=
this
.
playlistUriToUrl
(
segment
.
uri
);
this
.
loadSegment
(
segmentUri
,
offset
);
};
videojs
.
Hls
.
prototype
.
playlistUriToUrl
=
function
(
segmentRelativeUrl
)
{
var
playListUrl
;
// resolve the segment URL relative to the playlist
if
(
this
.
playlists
.
media
().
uri
===
this
.
src_
)
{
segmentUri
=
resolveUrl
(
this
.
src_
,
segment
.
uri
);
playListUrl
=
resolveUrl
(
this
.
src_
,
segmentRelativeUrl
);
}
else
{
segmentUri
=
resolveUrl
(
resolveUrl
(
this
.
src_
,
this
.
playlists
.
media
().
uri
||
''
),
segment
.
uri
);
playListUrl
=
resolveUrl
(
resolveUrl
(
this
.
src_
,
this
.
playlists
.
media
().
uri
||
''
),
segmentRelativeUrl
);
}
this
.
loadSegment
(
segmentUri
,
offset
);
return
playListUrl
;
};
/*
...
...
@@ -684,7 +691,7 @@ videojs.Hls.prototype.fetchKeys = function(playlist, index) {
key
=
playlist
.
segments
[
i
].
key
;
if
(
key
&&
!
key
.
bytes
&&
!
keyFailed
(
key
))
{
keyXhr
=
videojs
.
Hls
.
xhr
({
url
:
resolveUrl
(
playlist
.
uri
,
key
.
uri
),
url
:
this
.
playlistUriToUrl
(
key
.
uri
),
responseType
:
'arraybuffer'
,
withCredentials
:
settings
.
withCredentials
},
function
(
err
,
url
)
{
...
...
test/videojs-hls_test.js
View file @
66510e6
...
...
@@ -1612,6 +1612,48 @@ test('calling fetchKeys() when a new playlist is loaded will create an XHR', fun
player
.
hls
.
playlists
.
media
=
oldMedia
;
});
test
(
'fetchKeys() resolves URLs relative to the master playlist'
,
function
()
{
player
.
src
({
src
:
'video/master-encrypted.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
requests
.
shift
().
respond
(
200
,
null
,
'#EXTM3U\n'
+
'#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=17\n'
+
'playlist/playlist.m3u8\n'
+
'#EXT-X-ENDLIST\n'
);
requests
.
shift
().
respond
(
200
,
null
,
'#EXTM3U\n'
+
'#EXT-X-TARGETDURATION:15\n'
+
'#EXT-X-KEY:METHOD=AES-128,URI="keys/key.php"\n'
+
'#EXTINF:2.833,\n'
+
'http://media.example.com/fileSequence1.ts\n'
+
'#EXT-X-ENDLIST\n'
);
equal
(
requests
.
length
,
2
,
'requested two URLs'
);
ok
((
/video
\/
playlist
\/
keys
\/
key
\.
php$/
).
test
(
requests
[
0
].
url
),
'resolves multiple relative paths'
);
});
test
(
'fetchKeys() resolves URLs relative to their containing playlist'
,
function
()
{
player
.
src
({
src
:
'video/media-encrypted.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
openMediaSource
(
player
);
requests
.
shift
().
respond
(
200
,
null
,
'#EXTM3U\n'
+
'#EXT-X-TARGETDURATION:15\n'
+
'#EXT-X-KEY:METHOD=AES-128,URI="keys/key.php"\n'
+
'#EXTINF:2.833,\n'
+
'http://media.example.com/fileSequence1.ts\n'
+
'#EXT-X-ENDLIST\n'
);
equal
(
requests
.
length
,
2
,
'requested two URLs'
);
ok
((
/video
\/
keys
\/
key
\.
php$/
).
test
(
requests
[
0
].
url
),
'resolves multiple relative paths'
);
});
test
(
'a new keys XHR is created when a previous key XHR finishes'
,
function
()
{
player
.
src
({
src
:
'https://example.com/encrypted-media.m3u8'
,
...
...
Please
register
or
sign in
to post a comment