So I have an embedded video field inside of a paragraph and want it to autoplay. I have set the settings for the field to have it autoplay, but when the iframe is rendered the url has autoplay=0. Are there other settings I need to enable to get this to work?
Use the following code to change autoplay to 1 in your template or Javascript file. It works for me.
jQuery('.video-embed-field-launch-modal').attr('data-video-embed-field-modal', function(i, oldSrc) {
var isAutoPlay = oldSrc.match(/autoplay=([^&]*)/);
if (isAutoPlay && isAutoPlay[1] == 0) {
return oldSrc.replace('autoplay=0', 'autoplay=1');
}
});
Some extra info to add ... Google has updated their policy around auto play on websites .. To get auto play to work you need to add &mute=1 to the query string so that the sound is muted when the page loads and the video starts
See the policy here:
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
Without that parameter .. Chrome won't auto play at all .. Currently auto play with sound on Firefox 63, Edge & IE 11 without the above parameter. Chrome won't auto play without the mute setting. Opera 56 doesn't appear to auto play at all.