Looping, increase/decrease volume fix
This commit is contained in:
parent
1a5f4b1b9e
commit
c948e95ade
2
dist/plyr.js
vendored
2
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.js.map
vendored
2
dist/plyr.js.map
vendored
File diff suppressed because one or more lines are too long
@ -145,7 +145,7 @@ const listeners = {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 73:
|
/* case 73:
|
||||||
this.setLoop('start');
|
this.setLoop('start');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ const listeners = {
|
|||||||
|
|
||||||
case 79:
|
case 79:
|
||||||
this.setLoop('end');
|
this.setLoop('end');
|
||||||
break;
|
break; */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -53,7 +53,7 @@ const vimeo = {
|
|||||||
// Get Vimeo params for the iframe
|
// Get Vimeo params for the iframe
|
||||||
const options = {
|
const options = {
|
||||||
loop: player.config.loop.active,
|
loop: player.config.loop.active,
|
||||||
autoplay: player.config.autoplay,
|
autoplay: player.autoplay,
|
||||||
byline: false,
|
byline: false,
|
||||||
portrait: false,
|
portrait: false,
|
||||||
title: false,
|
title: false,
|
||||||
@ -155,6 +155,18 @@ const vimeo = {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Loop
|
||||||
|
let { loop } = player.media;
|
||||||
|
Object.defineProperty(player.media, 'loop', {
|
||||||
|
get() {
|
||||||
|
return loop;
|
||||||
|
},
|
||||||
|
set(input) {
|
||||||
|
loop = utils.is.boolean(input) ? input : player.config.loop.active;
|
||||||
|
player.embed.setLoop(loop);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Source
|
// Source
|
||||||
let currentSrc;
|
let currentSrc;
|
||||||
player.embed.getVideoUrl().then(value => {
|
player.embed.getVideoUrl().then(value => {
|
||||||
|
@ -76,7 +76,7 @@ const youtube = {
|
|||||||
widget_referrer: window && window.location.href,
|
widget_referrer: window && window.location.href,
|
||||||
|
|
||||||
// Captions are flaky on YouTube
|
// Captions are flaky on YouTube
|
||||||
cc_load_policy: (this.captions.active ? 1 : 0),
|
cc_load_policy: this.captions.active ? 1 : 0,
|
||||||
cc_lang_pref: this.config.captions.language,
|
cc_lang_pref: this.config.captions.language,
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
@ -246,17 +246,14 @@ const youtube = {
|
|||||||
switch (event.data) {
|
switch (event.data) {
|
||||||
case 0:
|
case 0:
|
||||||
// YouTube doesn't support loop for a single video, so mimick it.
|
// YouTube doesn't support loop for a single video, so mimick it.
|
||||||
if (player.config.loop.active) {
|
if (player.media.loop) {
|
||||||
// YouTube needs a call to `stopVideo` before playing again
|
// YouTube needs a call to `stopVideo` before playing again
|
||||||
instance.stopVideo();
|
instance.stopVideo();
|
||||||
instance.playVideo();
|
instance.playVideo();
|
||||||
|
} else {
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.media.paused = true;
|
|
||||||
|
|
||||||
utils.dispatchEvent.call(player, player.media, 'ended');
|
utils.dispatchEvent.call(player, player.media, 'ended');
|
||||||
|
player.media.paused = true;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// Plyr
|
// Plyr
|
||||||
// plyr.js v3.0.0
|
// plyr.js v3.0.0
|
||||||
// https://github.com/sampotts/plyr
|
// https://github.com/sampotts/plyr
|
||||||
@ -419,16 +419,16 @@ class Plyr {
|
|||||||
|
|
||||||
// Increase volume
|
// Increase volume
|
||||||
increaseVolume(step) {
|
increaseVolume(step) {
|
||||||
const volume = this.media.muted ? 0 : this.media.volume;
|
const volume = this.media.muted ? 0 : this.volume;
|
||||||
|
this.volume = volume + utils.is.number(step) ? step : 1;
|
||||||
return this.setVolume(volume + utils.is.number(step) ? step : 1);
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decrease volume
|
// Decrease volume
|
||||||
decreaseVolume(step) {
|
decreaseVolume(step) {
|
||||||
const volume = this.media.muted ? 0 : this.media.volume;
|
const volume = this.media.muted ? 0 : this.volume;
|
||||||
|
this.volume = volume - utils.is.number(step) ? step : 1;
|
||||||
return this.setVolume(volume - utils.is.number(step) ? step : 1);
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle mute
|
// Toggle mute
|
||||||
@ -517,11 +517,14 @@ class Plyr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Toggle loop
|
// Toggle loop
|
||||||
// TODO: Finish logic
|
// TODO: Finish fancy new logic. Set the indicator on load as user may pass loop as config
|
||||||
// TODO: Set the indicator on load as user may pass loop as config
|
set loop(input) {
|
||||||
/* loop(input) {
|
const toggle = utils.is.boolean(input) ? input : this.config.loop.active;
|
||||||
|
this.config.loop.active = toggle;
|
||||||
|
this.media.loop = toggle;
|
||||||
|
|
||||||
// Set default to be a true toggle
|
// Set default to be a true toggle
|
||||||
const type = ['start', 'end', 'all', 'none', 'toggle'].includes(input) ? input : 'toggle';
|
/* const type = ['start', 'end', 'all', 'none', 'toggle'].includes(input) ? input : 'toggle';
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'start':
|
case 'start':
|
||||||
@ -561,11 +564,12 @@ class Plyr {
|
|||||||
this.config.loop.start = 0;
|
this.config.loop.start = 0;
|
||||||
this.config.loop.end = null;
|
this.config.loop.end = null;
|
||||||
break;
|
break;
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow chaining
|
get loop() {
|
||||||
return this;
|
return this.media.loop;
|
||||||
} */
|
}
|
||||||
|
|
||||||
// Media source
|
// Media source
|
||||||
set src(input) {
|
set src(input) {
|
||||||
@ -596,6 +600,15 @@ class Plyr {
|
|||||||
return this.media.getAttribute('poster');
|
return this.media.getAttribute('poster');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Autoplay
|
||||||
|
get autoplay() {
|
||||||
|
return this.config.autoplay;
|
||||||
|
}
|
||||||
|
set autoplay(input) {
|
||||||
|
const toggle = utils.is.boolean(input) ? input : this.config.autoplay;
|
||||||
|
this.config.autoplay = toggle;
|
||||||
|
}
|
||||||
|
|
||||||
// Toggle captions
|
// Toggle captions
|
||||||
toggleCaptions(input) {
|
toggleCaptions(input) {
|
||||||
// If there's no full support, or there's no caption toggle
|
// If there's no full support, or there's no caption toggle
|
||||||
|
@ -71,12 +71,13 @@ const ui = {
|
|||||||
|
|
||||||
// Set volume
|
// Set volume
|
||||||
this.volume = null;
|
this.volume = null;
|
||||||
|
// this.muted = null;
|
||||||
|
|
||||||
// Set playback speed
|
// Set playback speed
|
||||||
this.speed = null;
|
this.speed = null;
|
||||||
|
|
||||||
// Set loop
|
// Set loop
|
||||||
// this.setLoop();
|
this.loop = null;
|
||||||
|
|
||||||
// Reset time display
|
// Reset time display
|
||||||
ui.timeUpdate.call(this);
|
ui.timeUpdate.call(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user