Reputation: 5106
I want to create a video streaming website, like youtube and I've been stuck on 2 requirements which I'm not sure if videojs
solves or not.
videojs-contrib-hls
and saw and by looking in the demo and the adaptive bitrate switching documentation, it seems that the quality of the video is chosen automatically by some policy (which can be overridden), but cannot be chosen specifically by the user.I was wondering if maybe I'm not understanding things correctly? Are browsers smart enough to achieve my 1st requirement on their own?
Upvotes: 1
Views: 2542
Reputation: 205
You can fulfill your 2nd requirement by following way.
//initilaize your player
var player = videojs(element_id);
player.ready(function () {
player.src({
src: hls_url,
type: 'application/x-mpegURL'
});
player.play();
});
player.on('loadedmetadata', function () {
var _hls = player.hls;
//get quality list
var quality_list = _hls.representations(); //load it to your custom dropdown
//you can change quality using below (it will select quality greater than 720)
_hls.representations().forEach(function (rep) {
//you can change the condition as per your dropdown selection
if (rep.width > 720) {
rep.enabled(true); //select this quality
} else {
rep.enabled(false); //disable this quality
}
});
})
Upvotes: 1