Work on quality control

This commit is contained in:
Sam Potts 2017-08-06 21:00:31 +10:00
parent f7144dc0cb
commit f6a7555a1d
3 changed files with 51 additions and 9 deletions

2
demo/dist/demo.js vendored

File diff suppressed because one or more lines are too long

4
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -131,8 +131,8 @@
// Quality settings // Quality settings
quality: { quality: {
default: 'auto', selected: 'auto',
selected: 'auto' options: []
}, },
// Set loops // Set loops
@ -3863,7 +3863,7 @@
// Settings - Quality // Settings - Quality
else if (utils.matches(event.target, player.config.selectors.inputs.quality)) { else if (utils.matches(event.target, player.config.selectors.inputs.quality)) {
handlerProxy.call(this, event, player.config.listeners.quality, function() { handlerProxy.call(this, event, player.config.listeners.quality, function() {
warn("Set quality"); player.setQuality(event.target.value);
}); });
} }
@ -3879,11 +3879,13 @@
else if (utils.matches(event.target, player.config.selectors.buttons.loop)) { else if (utils.matches(event.target, player.config.selectors.buttons.loop)) {
handlerProxy.call(this, event, player.config.listeners.loop, function() { handlerProxy.call(this, event, player.config.listeners.loop, function() {
// TODO: This should be done in the method itself I think // TODO: This should be done in the method itself I think
var value = event.target.getAttribute('data-loop__value') || event.target.getAttribute('data-loop__type'); // var value = event.target.getAttribute('data-loop__value') || event.target.getAttribute('data-loop__type');
if (utils.inArray(['start', 'end', 'all', 'none'], value)) { warn('Set loop');
/*if (utils.inArray(['start', 'end', 'all', 'none'], value)) {
player.loop(value); player.loop(value);
} }*/
}); });
} }
}); });
@ -4647,6 +4649,7 @@
break; break;
case 'vimeo': case 'vimeo':
speed = null;
// Vimeo not supported (https://github.com/vimeo/player.js) // Vimeo not supported (https://github.com/vimeo/player.js)
player.core.warn('Vimeo playback rate change is not supported'); player.core.warn('Vimeo playback rate change is not supported');
break; break;
@ -4656,6 +4659,45 @@
break; break;
} }
// Save speed to localStorage
player.core.updateStorage({
speed: speed
});
// Allow chaining
return player;
};
// Set playback quality
Plyr.prototype.setQuality = function(quality) {
var player = this;
// Load speed from storage or default value
if (!utils.is.string(quality)) {
quality = parseFloat(player.storage.quality || player.config.quality.selected);
}
if (!utils.inArray(player.config.quality.options, quality)) {
player.core.warn('Unsupported quality option (' + quality + ')');
return;
}
// Set media speed
switch (player.type) {
case 'youtube':
player.embed.setPlaybackQuality(quality);
break;
default:
player.core.warn('Quality options are only available for YouTube');
break;
}
// Save speed to localStorage
player.core.updateStorage({
quality: quality
});
// Allow chaining // Allow chaining
return player; return player;
}; };