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
11157fa5
authored
2015-05-19 17:50:17 -0400
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #265 from videojs/preload-none
Respect the preload-none option
2 parents
5c4a7c05
bca4ff16
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
6 deletions
example.html
package.json
src/videojs-hls.js
test/videojs-hls_test.js
example.html
View file @
11157fa
...
...
@@ -5,9 +5,9 @@
<title>
video.js HLS Plugin Example
</title>
<link
href=
"node_modules/video.js/dist/video-js/video-js.css"
rel=
"stylesheet"
>
<!-- video.js -->
<script
src=
"node_modules/video.js/dist/video-js/video.js"
></script>
<script
src=
"node_modules/video.js/dist/video-js/video.
dev.
js"
></script>
<!-- Media Sources plugin -->
<script
src=
"node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js"
></script>
...
...
package.json
View file @
11157fa
...
...
@@ -45,6 +45,6 @@
"dependencies"
:
{
"pkcs7"
:
"^0.2.2"
,
"videojs-contrib-media-sources"
:
"^1.0.0"
,
"videojs-swf"
:
"^4.
6
.0"
"videojs-swf"
:
"^4.
7
.0"
}
}
...
...
src/videojs-hls.js
View file @
11157fa
...
...
@@ -143,9 +143,6 @@ videojs.Hls.prototype.src = function(src) {
setupEvents
=
function
()
{
this
.
fillBuffer
();
player
.
trigger
(
'loadedmetadata'
);
};
...
...
@@ -558,6 +555,12 @@ videojs.Hls.prototype.fillBuffer = function(offset) {
segment
,
segmentUri
;
// if preload is set to "none", do not download segments until playback is requested
if
(
!
player
.
hasClass
(
'vjs-has-started'
)
&&
player
.
options
().
preload
===
'none'
)
{
return
;
}
// if a video has not been specified, do nothing
if
(
!
player
.
currentSrc
()
||
!
this
.
playlists
)
{
return
;
...
...
test/videojs-hls_test.js
View file @
11157fa
...
...
@@ -2299,4 +2299,34 @@ test('live stream should not call endOfStream', function(){
"media source should be in open state, not ended state for live stream after the last segment in m3u8 downloaded"
);
});
test
(
'does not download segments if preload option set to none'
,
function
()
{
var
loadedSegments
=
0
,
tech
=
player
.
el
().
querySelector
(
'.vjs-tech'
),
properties
=
{};
player
.
src
({
src
:
'master.m3u8'
,
type
:
'application/vnd.apple.mpegurl'
});
tech
.
vjs_getProperty
=
function
(
property
)
{
return
properties
[
property
];
};
tech
.
vjs_setProperty
=
function
(
property
,
value
)
{
properties
[
property
]
=
value
;
};
player
.
preload
(
'none'
);
player
.
hls
.
loadSegment
=
function
()
{
loadedSegments
++
;
};
player
.
currentSrc
=
function
()
{
return
player
.
src
;
};
openMediaSource
(
player
);
standardXHRResponse
(
requests
.
shift
());
// master
standardXHRResponse
(
requests
.
shift
());
// media
player
.
hls
.
checkBuffer_
();
strictEqual
(
loadedSegments
,
0
,
'did not download any segments'
);
});
})(
window
,
window
.
videojs
);
...
...
Please
register
or
sign in
to post a comment