npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

videojs-resolution-selector

v1.6.2

Published

Adds a resolution selector button to Video.js to allow users to manually adjust the video quality.

Downloads

657

Readme

#Video.js Resolution Selector Add a resolution selector button to Video.js to allow users to manually adjust the video quality.

##Install You can use bower (bower install videojs-resolution-selector), npm (npm install videojs-resolution-selector), or simply download the source from this repo. You must be running Video.js 4.7.3 or higher for this plugin to function. You can download the latest source at the main Video.js repo, or you can get production files from videojs.com, or you can use the CDN files.

##Usage Add an extra attribute to your <source /> elements.

<video>
	<source data-res="480" src="..." type="..." />
	<source data-res="240" src="..." type="..." />
</video>

Enable the plugin as described in the video.js docs. Optionally, you can pass some settings to the plugin:

videojs( '#my-video', { plugins : { resolutionSelector : {
	force_types	: [ 'video/mp4', 'video/webm' ],
	default_res	: "480"
} } } );

force_types is an array. The plugin will check each resolution to make sure there is a source of each type at that resolution.

default_res must be a string. You can either specify a single resolution or a comma separated list (e.g. "480,240"). When using a list, the first available resolution in the list will be selected by default.

The plugin also triggers a changeRes event on the player instance anytime the resolution is changed, so your code can listen for that and take any desired action on resolution changes:

videojs( '#my-video', { plugins : { resolutionSelector : {} } }, function() {
	
	var player = this;
	
	player.on( 'changeRes', function() {
		
		console.log( 'Current Res is: ' + player.getCurrentRes() );
	});
});

The plugin provides a changeRes method on the player object. You can call it like so (after your player is ready): player.changeRes( '480' ).

##Simple Example

<!DOCTYPE html>
<html>
<head>
	<link href="//vjs.zencdn.net/4.5/video-js.css" rel="stylesheet" />
	<script src="//vjs.zencdn.net/4.5/video.js"></script>
	<link href="video-quality-selector.css" rel="stylesheet" type="text/css" />
	<script src="video-quality-selector.js"></script>
</head>
<body>
	<video id="example-2" class="video-js vjs-default-skin" controls width="640" height="360" data-setup='{ "plugins" : { "resolutionSelector" : { "default_res" : "480" } } }'>
		<source src="video-360.mp4" type="video/mp4" data-res="360" />
		<source src="video-480.mp4" type="video/mp4" data-res="480" />
	</video>
</body>
</html>

Please see example.html for a more advanced example.

##Styling the Button By default, the button will not be visible. You will either need to include the styles from video-quality-selector.css (after the default Video.js styles to override them), or use your own icon for the button. To match the rest of the Video.js controls, I recommend using an icon font to style the button, but it's up to you.

##Mobile devices If you want this plugin to work on mobile devices, you need to enable the video.js controls because the native controls are default on iOS and Android.

<video data-setup='{"customControlsOnMobile": true}'>
    ...
</video>