Autoplay bug fixes

This commit is contained in:
Sam Potts
2016-03-14 22:50:34 +11:00
parent 33771ef8c0
commit 815100cff8
2 changed files with 18 additions and 22 deletions

4
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1319,12 +1319,6 @@
// Clean up // Clean up
plyr.embedId = null; plyr.embedId = null;
} }
else {
// Autoplay
if (config.autoplay) {
_play();
}
}
} }
// Setup YouTube/Vimeo // Setup YouTube/Vimeo
@ -1438,7 +1432,7 @@
plyr.embed = new YT.Player(container.id, { plyr.embed = new YT.Player(container.id, {
videoId: videoId, videoId: videoId,
playerVars: { playerVars: {
autoplay: plyr.autoplay ? 1 : 0, autoplay: (config.autoplay ? 1 : 0),
controls: (plyr.supported.full ? 0 : 1), controls: (plyr.supported.full ? 0 : 1),
rel: 0, rel: 0,
showinfo: 0, showinfo: 0,
@ -1626,12 +1620,12 @@
}); });
// Always seek to 0 // Always seek to 0
//plyr.embed.api('seekTo', 0); // plyr.embed.api('seekTo', 0);
// Prevent autoplay if needed (seek will play) // Autoplay
//if (!config.autoplay) { if (config.autoplay) {
// plyr.embed.api('pause'); plyr.embed.api('play');
//} }
}); });
} }
@ -2277,6 +2271,11 @@
// Inject the new element // Inject the new element
_prependChild(plyr.container, plyr.media); _prependChild(plyr.container, plyr.media);
// Autoplay the new source?
if (typeof source.autoplay !== 'undefined') {
config.autoplay = source.autoplay;
}
// Set attributes for audio video // Set attributes for audio video
if (_inArray(config.types.html5, plyr.type)) { if (_inArray(config.types.html5, plyr.type)) {
if (config.crossorigin) { if (config.crossorigin) {
@ -2301,9 +2300,6 @@
_toggleClass(plyr.container, config.classes.captions.active, plyr.captionsEnabled); _toggleClass(plyr.container, config.classes.captions.active, plyr.captionsEnabled);
_toggleStyleHook(); _toggleStyleHook();
// Autoplay the new source?
config.autoplay = (source.autoplay || config.autoplay);
// Set new sources for html5 // Set new sources for html5
if (_inArray(config.types.html5, plyr.type)) { if (_inArray(config.types.html5, plyr.type)) {
_insertChildElements('source', source.sources); _insertChildElements('source', source.sources);
@ -2329,11 +2325,6 @@
_displayDuration(); _displayDuration();
} }
// Play if autoplay attribute is present
if (config.autoplay) {
_play();
}
// Set aria title and iframe title // Set aria title and iframe title
config.title = source.title; config.title = source.title;
_setTitle(); _setTitle();
@ -2668,6 +2659,11 @@
// Set title on button and frame // Set title on button and frame
_setTitle(); _setTitle();
// Autoplay
if (config.autoplay) {
_play();
}
} }
// Successful setup // Successful setup