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
c64d4a02
authored
2014-04-15 16:03:35 -0400
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #35 from videojs/withcredentials
Withcredentials
2 parents
45ec53ae
5587efc9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
24 deletions
package.json
src/videojs-hls.js
test/.jshintrc
test/videojs-hls.html
test/videojs-hls_test.js
package.json
View file @
c64d4a0
...
...
@@ -13,27 +13,28 @@
"test"
:
"grunt test-local"
},
"devDependencies"
:
{
"grunt"
:
"~0.4.1"
,
"grunt-concurrent"
:
"0.4.3"
,
"grunt-contrib-clean"
:
"~0.4.0"
,
"grunt-contrib-concat"
:
"~0.3.0"
,
"grunt-contrib-connect"
:
"~0.6.0"
,
"grunt-contrib-jshint"
:
"~0.6.0"
,
"grunt-contrib-qunit"
:
"~0.2.0"
,
"grunt-contrib-concat"
:
"~0.3.0"
,
"grunt-contrib-uglify"
:
"~0.2.0"
,
"grunt-contrib-watch"
:
"~0.4.0"
,
"grunt-contrib-clean"
:
"~0.4.0"
,
"grunt-contrib-connect"
:
"~0.6.0"
,
"grunt-concurrent"
:
"0.4.3"
,
"grunt-karma"
:
"~0.6.2"
,
"grunt-open"
:
"0.2.3"
,
"grunt-shell"
:
"0.6.1"
,
"grunt"
:
"~0.4.1"
,
"grunt-karma"
:
"~0.6.2"
,
"karma"
:
"~0.10.0"
,
"karma-sauce-launcher"
:
"~0.1.8"
,
"karma-chrome-launcher"
:
"~0.1.2"
,
"karma-firefox-launcher"
:
"~0.1.3"
,
"karma-ie-launcher"
:
"~0.1.1"
,
"karma-opera-launcher"
:
"~0.1.0"
,
"karma-phantomjs-launcher"
:
"~0.1.1"
,
"karma-safari-launcher"
:
"~0.1.1"
,
"karma-qunit"
:
"~0.1.1"
,
"karma-safari-launcher"
:
"~0.1.1"
,
"karma-sauce-launcher"
:
"~0.1.8"
,
"sinon"
:
"^1.9.1"
,
"video.js"
:
"^4.5"
},
"peerDependencies"
:
{
...
...
src/videojs-hls.js
View file @
c64d4a0
...
...
@@ -31,6 +31,9 @@ videojs.hls = {
};
var
settings
,
// the desired length of video to maintain in the buffer, in seconds
goalBufferLength
=
5
,
...
...
@@ -109,12 +112,26 @@ var
method
:
'GET'
},
request
;
if
(
typeof
callback
!==
'function'
)
{
callback
=
function
()
{};
}
if
(
typeof
url
===
'object'
)
{
options
=
videojs
.
util
.
mergeOptions
(
options
,
url
);
url
=
options
.
url
;
}
request
=
new
window
.
XMLHttpRequest
();
request
.
open
(
options
.
method
,
url
);
if
(
options
.
responseType
)
{
request
.
responseType
=
options
.
responseType
;
}
if
(
settings
.
withCredentials
)
{
request
.
withCredentials
=
true
;
}
request
.
onreadystatechange
=
function
()
{
// wait until the request completes
if
(
this
.
readyState
!==
4
)
{
...
...
@@ -286,6 +303,8 @@ var
return
;
}
settings
=
videojs
.
util
.
mergeOptions
({},
options
);
srcUrl
=
(
function
()
{
var
extname
,
...
...
@@ -299,7 +318,7 @@ var
// use the URL specified in options if one was provided
if
(
typeof
options
===
'string'
)
{
return
options
;
}
else
if
(
options
)
{
}
else
if
(
options
&&
options
.
url
)
{
return
options
.
url
;
}
...
...
@@ -627,24 +646,20 @@ var
segment
.
uri
);
}
// request the next segment
segmentXhr
=
new
window
.
XMLHttpRequest
();
segmentXhr
.
open
(
'GET'
,
segmentUri
);
segmentXhr
.
responseType
=
'arraybuffer'
;
segmentXhr
.
onreadystatechange
=
function
()
{
// wait until the request completes
if
(
this
.
readyState
!==
4
)
{
return
;
}
startTime
=
+
new
Date
();
// request the next segment
segmentXhr
=
xhr
({
url
:
segmentUri
,
responseType
:
'arraybuffer'
},
function
(
error
,
url
)
{
// the segment request is no longer outstanding
segmentXhr
=
null
;
// trigger an error if the request was not successful
if
(
this
.
status
>=
400
)
{
if
(
error
)
{
player
.
hls
.
error
=
{
status
:
this
.
status
,
message
:
'HLS segment request error at URL: '
+
segmentUri
,
message
:
'HLS segment request error at URL: '
+
url
,
code
:
(
this
.
status
>=
500
)
?
4
:
2
};
...
...
@@ -694,9 +709,7 @@ var
// figure out what stream the next segment should be downloaded from
// with the updated bandwidth information
updateCurrentPlaylist
();
};
startTime
=
+
new
Date
();
segmentXhr
.
send
(
null
);
});
};
// load the MediaSource into the player
...
...
test/.jshintrc
View file @
c64d4a0
...
...
@@ -28,6 +28,7 @@
"strictEqual",
"notStrictEqual",
"throws",
"sinon",
"process"
]
}
...
...
test/videojs-hls.html
View file @
c64d4a0
...
...
@@ -3,6 +3,12 @@
<head>
<meta
charset=
"utf-8"
>
<title>
video.js HLS Plugin Test Suite
</title>
<!-- Load sinon server for fakeXHR -->
<script
src=
"../node_modules/sinon/lib/sinon.js"
></script>
<script
src=
"../node_modules/sinon/lib/sinon/util/event.js"
></script>
<script
src=
"../node_modules/sinon/lib/sinon/util/xhr_ie.js"
></script>
<script
src=
"../node_modules/sinon/lib/sinon/util/fake_xml_http_request.js"
></script>
<!-- Load local QUnit. -->
<link
rel=
"stylesheet"
href=
"../libs/qunit/qunit.css"
media=
"screen"
>
<script
src=
"../libs/qunit/qunit.js"
></script>
...
...
test/videojs-hls_test.js
View file @
c64d4a0
This diff is collapsed.
Click to expand it.
Please
register
or
sign in
to post a comment