mirror of
https://github.com/kmoskwiak/videojs-resolution-switcher.git
synced 2025-10-03 09:49:21 +02:00
hls init
This commit is contained in:
parent
56760f6314
commit
2e5bb5ade7
3 changed files with 85 additions and 2 deletions
66
examples/hls.html
Normal file
66
examples/hls.html
Normal file
|
@ -0,0 +1,66 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Video.js Resolution Switcher</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="../node_modules/video.js/dist/video-js.css" rel="stylesheet">
|
||||
<link href="../lib/videojs-resolution-switcher.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #777;
|
||||
}
|
||||
.info {
|
||||
background-color: #eee;
|
||||
border: thin solid #333;
|
||||
border-radius: 3px;
|
||||
padding: 0 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.video-js {
|
||||
margin: 40px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="info">
|
||||
<p>
|
||||
HLS tech
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<video id="video" class="video-js"></video>
|
||||
|
||||
<script src="../node_modules/video.js/dist/video.js"></script>
|
||||
<script src="../node_modules/videojs-contrib-hls/dist/videojs.hls.min.js"></script>
|
||||
<script src="../lib/videojs-resolution-switcher.js"></script>
|
||||
<script>
|
||||
// fire up the plugin
|
||||
videojs('video', {
|
||||
controls: true,
|
||||
muted: true,
|
||||
width: 1000,
|
||||
plugins: {
|
||||
videoJsResolutionSwitcher: {
|
||||
default: 'low', // Default resolution [{Number}, 'low', 'high'],
|
||||
dynamicLabel: true // Display dynamic labels or gear symbol
|
||||
}
|
||||
}
|
||||
}, function(){
|
||||
var player = this;
|
||||
window.player = player
|
||||
|
||||
player.src({
|
||||
src: '//s3.amazonaws.com/_bc_dml/example-content/tears-of-steel/playlist.m3u8',
|
||||
type: 'application/x-mpegURL'
|
||||
})
|
||||
|
||||
player.on('resolutionchange', function(){
|
||||
console.info('Source changed to %s', player.src())
|
||||
})
|
||||
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -337,6 +337,17 @@
|
|||
});
|
||||
}
|
||||
|
||||
function initResolutionForHLS(player){
|
||||
var hls = player.tech_.hls;
|
||||
|
||||
player.one('loadedmetadata', function(){
|
||||
var playlists = hls.playlists.master.playlists;
|
||||
console.log(playlists)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
player.ready(function(){
|
||||
if(player.options_.sources.length > 1){
|
||||
// tech: Html5 and Flash
|
||||
|
@ -344,6 +355,11 @@
|
|||
player.updateSrc(player.options_.sources);
|
||||
}
|
||||
|
||||
if(player.tech_.hls){
|
||||
// HLS support
|
||||
initResolutionForHLS(player);
|
||||
}
|
||||
|
||||
if(player.techName_ === 'Youtube'){
|
||||
// tech: YouTube
|
||||
initResolutionForYt(player);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"url": "git@github.com:kmoskwiak/videojs-resolution-switcher.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kmoskwiak/videojs-resolution-switcher/issues"
|
||||
"url": "https://github.com/khmoskwiak/videojs-resolution-switcher/issues"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"keywords": [
|
||||
|
@ -44,7 +44,8 @@
|
|||
"grunt-contrib-watch": "^1.0",
|
||||
"video.js": "^5.8",
|
||||
"qunitjs": "^1.22",
|
||||
"videojs-youtube": "^2.0.8"
|
||||
"videojs-youtube": "^2.0.8",
|
||||
"videojs-contrib-hls": "^1.3.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"video.js": "^5.8"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue