Chrome 65, the current canary version, is blocking iframed youtube videos from auto playing with sound.
The latest changes to Chrome require the iframe to have allow="autoplay"
How do I go about adding allow="autoplay" to the youtube iframe api? I can't find it in any of the documentation.
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes#iframe
A feature policy allows developers to selectively enable and disable use of various browser features and APIs. Once an origin has received autoplay permission, it can delegate that permission to cross-origin iframes with a new feature policy for autoplay. Note that autoplay is allowed by default on same-origin iframes.
<iframe src="myvideo.html" allow="autoplay">
The YouTube IFrame API has been recently updated to use allow=autoplay instead of gesture=media. It should now work as expected.
Sorry for the confusion.
You just add it in the src URL like:
autoplay
This parameter specifies whether the initial video will automatically
start to play when the player loads. Supported values are 0 or 1. The
default value is 0.
Related
New Squarespace, Vimeo, and iFrame user here. I'm doing some work for a non-profit, and they've asked me to create a "Testimonials" page with ~10 videos where the controls of each are revealed only on hover.
On load / inactive state
When the video loads, there shouldn't be any controls; sharing; or title/byline visible.
On hover
On hover, the user should see the player controls.
What I've tried
Given the basic iFrame embed code:
<iframe src="https://player.vimeo.com/video/58659769" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
✅?title=0&byline=0&portrait=0 gets rid of the title, owner name, and owner avatar of Vimeo accounts, regardless of paid status. This is a step in the right direction!
🛑?controls=0 gets rid of all controls for Pro+ videos, which is the desired start state. However, the only way to then play the videos is via autoplay=1: https://developer.vimeo.com/player/sdk/embed. This wouldn't work with multiple videos on the page. Also, we don't have a paid Vimeo account.
🛑Targeting the elements with a { display: none; } works when in my Dev Tools Panel after page load. However, I can't produce the same effect via the Custom CSS panel -- I suspect due to Vimeo server-side restrictions. (It hides the elements at first, then renders them after ~3 seconds.)
🛑I can't inject custom Javascript into the site via Developer Mode because we're only using the basic Squarespace, so all JS solutions are currently blocked. However, I may be able to get them to pay to upgrade Squarespace, so JS solutions are welcome!
🛑Injecting <script> tags into the embed modal doesn't execute the code
I know this would be possible from the Vimeo development side because the desired event happens when I've started to play the video. After pausing a video that has been playing, the controls disappear, and then reappear on mouse movement over the video.
The closest thing I could find was using Frogaloop (https://forum.webflow.com/t/play-vimeo-video-on-hover-from-a-cms-collection/78458). However, given JavaScript restrictions, I don't know how to execute something similar in Squarespace.
Credit
The video stills are just for testing, given that I know that it is uploaded to a user with a Vimeo Plus account. Thanks to Bianca Giaever! https://vimeo.com/58659769
I was able to connect with the folks on the #VimeoStaff Twitter account, who provided me with the following answer. TL;DR: what I'm attempting to do isn't possible, but there are some (suboptimal) workarounds.
As you've found, you can control settings individually (such as the
title and byline) within the Embed tab of your video settings page.
I'm afraid it's not possible to change anything mid-load in JS,
meaning you won't be able to load the player with no controls and then
activate them with a hover. We're so sorry for any inconvenience! I'll
be sure to extend this feedback to our product team.
It is possible to remove the playbar from your embedded videos. You
can enable this feature by adding the ?background=1 parameter to the
end of the player URL in your embed code, for example:
<iframe src="https://player.vimeo.com/video/76979871?background=1"
width="640" height="360" frameborder="0" allow="autoplay; fullscreen"
allowfullscreen></iframe>
Adding this parameter will have the following effect:
All player toggles and elements will be turned off (including the play/pause button!)
The video will automatically loop.
The video will be set to autoplay
The video will be muted
If you would simply like to hide the UI of the player without
muting/autoplaying/looping (i.e for a chromeless player), you can
alternatively add the controls=0 to the end of the player URL in your
embed code, for example:
<iframe src="https://player.vimeo.com/video/76979871?controls=0"
width="640" height="360" frameborder="0" allow="autoplay; fullscreen"
allowfullscreen></iframe>
When using the controls embed parameter, you'll need to either enable
autoplay (?autoplay=1), use keyboard shortcuts, or implement our
player SDK to start and control playback.
More information on background and chromeless videos can be found
here. Please note that keyboard shortcuts cannot be disabled
currently.
Additionally, I can see you've mentioned having multiple videos on one
page. If you have more than one video autoplaying on a particular
page, you will also need to include this parameter: autopause=0
We have a number of video references in our web app which lazy load YouTube videos as embedded iframes. We want to have the videos autoplay so a single user click will suffice to load the YouTube iframe into the page and start its playback. We've had this working as recently as a few months ago, but the autoplay is no longer occurring. I know there was an update to Google/YouTube policies in the spring of 2018 which limited autoplay; has there been a more recent change I don't know about? Otherwise, does anyone know why this might have stopped working?
I've tried the most recent iframe examples I could find online, with several variations (e.g., with and without mute=1). None of these seem to work.
Here's an example of our iframe markup:
<iframe allow="autoplay" frameborder="0" allowfullscreen="" src="https://www.youtube.com/embed/sapLz6NjvJk?autoplay=1&origin=https://OurWebsiteDomain" title="Bug Week " height="278" data-ytbridge="vidSurrogate2" style="width: 100%;"></iframe>
Major browser have disabled these features due to general abuse.
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
https://blog.mozilla.org/firefox/block-autoplay/
YouTube checks upon loading whether it has permission to play how it wants to play the video. It will only autoplay if it has proper permission. The default in recent Chrome and Firefox builds is to only allow video - no sound. Adding &mute=1 the the youtube URL allows (muted) autoplay. This works if you don't necessarily need the sound, if you do then you will have to make the user click play themselves.
Applying this to the embed in your example:
<iframe allow="autoplay" frameborder="0" allowfullscreen="" src="https://www.youtube.com/embed/sapLz6NjvJk?autoplay=1&mute=1&origin=https://OurWebsiteDomain" title="Bug Week " height="278" data-ytbridge="vidSurrogate2" style="width: 100%;"></iframe>
This question already has an answer here:
getCurrentPosition deprecated on Google Apps iFrame?
(1 answer)
Closed 5 years ago.
I've been using Google Maps embedded within a site generated on script.google.com, using the HTML Service as follows:
HtmlService.createTemplateFromFile('index.html');
This has been fantastic, I've produced a web app with an embedded map (see https://script.google.com/macros/s/AKfycbzFiIPsnNgDnz8pmykbyok1xwDdL85EEAwqohoSo9G1QasbWNk/exec).
However, I am now warned that "getCurrentPosition and watchPosition usage in cross-origin iframes is deprecated and will be disabled in M63, around December 2017".
Trouble is, using HtmlService.createTemplateFromFile on script.google.com gives me no option (that I know of) to append allow="geolocation" to the iFrame (the HtmlService generates the iFrame automatically).This will cause the web app to fail in December.
Please advise what I should do to avoid issues!!!
Many thanks,
Sarah.
You may want to check these links: 1 and 2: Deprecating Permissions in Cross-Origin Iframes. In order for a cross-origin frame to use these features, the embedding page must specify a Feature Policy which enables the feature for the frame.
For example, to enable geolocation in an iframe, the embedder could specify the iframe tag as:
<iframe src="https://example.com" allow="geolocation"></iframe>
If you are a developer of a website which uses cross-origin iframes
and you want those iframes to continue to be able to request/use one
of the above features, the page that embeds the iframe will need to be
changed. The simplest way to do that is to modify the tag to
include an allow attribute which specifies the name of the permission.
For example, to enable geolocation and mic/camera for an iframe, the
following would be specified:
<iframe src="https://example.com" allow="geolocation; microphone; camera"></iframe>
Valid values for allow include:
geolocation
microphone
camera
midi
encrypted-media
Note that if the iframe which is using the permission has the same
origin as the top level page, then no changes have to be made.
Hope this helps!
I am deciding whether or not I should use the full YouTube API (registering for an API key, calling the YouTube JS and building the player from scratch) or if I should just register for an YouTube account, build a playlist and load this playlist on a client's website as is (using the iframe embed code, seen below):
<iframe width="100%" height="315"
src="https://www.youtube.com/embed/videoseries?list=XXXXXXX
&autoplay=1&rel=0&loop=1&shuffle=1" frameborder="0" allowfullscreen>
</iframe>
The embed code is easy enough, but from viewing earlier videos on YouTube Playlist settings, YouTube has removed quite a bit of functionality from basic playlist settings (autoplay, shuffling videos on play, start/stop times of each video in playlist, etc.)
I would imagine the switch for shuffle should be as easy as "&shuffle=1" or something like that. I'm not sure why YouTube makes it so difficult to comprehend new settings after having removed such a powerful feature from such a simple embed code.
Any ideas?
Here's an actual solution:
function onPlayerReady(event) {
event.target.playVideo();
setTimeout(setShuffleFunction, 1000);
}
function setShuffleFunction(){
player.setShuffle(true);
}
You have to use javascript to load the player.setShuffle(true) event, just after the first video starts (solution given here: YouTube API playlist shuffle). I didn't create it but I tried it and it worked for me too. I went two years thinking the feature was deprecated and no longer possible with embedded playlists. Seeing as this is the primary response when you google this issue, figured I'd help out.
You can find all the embed parameters YouTube supports here.
need the following list to work, anyone know what service best to use to do it?
Site members can upload videos from website site via API
Receive embed code immediately & embedded in the site
*Can control approved/unapproved - Can be marked as inappropriate - this is via kentico site
Check file type and Limit video to 30 seconds - this should be done before the upload
Video can be automatically watermarked with brand logo
I tried Vzaar but there support was terrible and could not get it to work.
YouTube - can branding be done there? Another issue is that the video is "saved" on the users account (user that uploaded) and can be added to my Chanel. this is NOT enough control over video.
Site is asp.net.
Any suggestions?
I have implemented this, but only works for mp4 videos. let the user upload the video onto your server. Embed it on to your website using Video tag in HTML5. for Water marking your video check out https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/3ca2162e-a374-415d-a430-59ad9e9135ab/digital-signature-on-video?forum=windowsdirectshowdevelopment
for editing video How to cut/crop/trim a video in respect with time or percentage and save output in different file
<video width="320" height="240" controls>
<source src='give path of file here' type="video/mp4">
//Text you want to display if html5 is not supported
Your browser does not support the video.
</video>