/*
* Videojs Plugin for download
* By: tutorialspots.com
* Base on Video.js Resolution Selector (https://github.com/dominic-p/videojs-resolution-selector)
* Thanks for Dominic P
*/
(function (_V_) {
var methods = {
res_label: function (res) {
return (/^\d+$/.test(res)) ? res + 'p' : res;
}
};
_V_.DownloadMenuItem = _V_.MenuItem.extend({
call_count: 0,
init: function (player, options) {
var touchstart = false;
// Modify options for parent MenuItem class's init.
options.label = methods.res_label(options.res);
// Call the parent constructor
_V_.MenuItem.call(this, player, options);
// Store the resolution as a property
this.resolution = options.res;
// Register our click and tap handlers
this.on(['click', 'tap'], this.onClick);
}
});
// Handle clicks on the menu items
_V_.DownloadMenuItem.prototype.onClick = function () {
// Check if this has already been called
if (this.call_count > 0) {
return;
}
// Call the player.changeDl method
this.player().changeDl(this.resolution);
// Increment the call counter
this.call_count++;
};
_V_.DownloadTitleMenuItem = _V_.MenuItem.extend({
init: function (player, options) {
// Call the parent constructor
_V_.MenuItem.call(this, player, options);
// No click handler for the menu title
this.off('click');
}
});
_V_.DownloadSelector = _V_.MenuButton.extend({
init: function (player, options) {
// Add our list of available resolutions to the player object
player.availableRes = options.available_res;
// Call the parent constructor
_V_.MenuButton.call(this, player, options);
// Set the button text based on the option provided
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.