Vimeo embed on Squarespace: hide controls on load, show on hover - iframe

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

Related

Embedded YouTube iframes No Longer Autoplay

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>

Hiding YouTube embed title and 'More videos' (Updated)

Is there an official way to hide the title and the More videos section from a YouTube embed (latest version as of July 2nd 2018), and just show the YouTube logo bottom-right? I know the embed used to have this ability some time ago.
What I'm basically looking for is have the embed auto play with no other elements on it except the mandatory YouTube logo and be able to pause it, but no More videos appear when doing that.
For the showinfo option, the documentation currently says:
Setting the parameter's value to 0 causes the player to not display
information like the video title and uploader before the video starts
playing.
So that before clearly says that this does not take effect during the video play.
But is there any way to hide the Uploader, Title, Watch Later and Share buttons from the top part of an embed?
This is how it currently looks when the video is paused:
<iframe src="https://www.youtube.com/embed/dnmJLVWetQM?autoplay=1&controls=0&modestbranding=1&showinfo=0&iv_load_policy=3" frameborder="0" allowfullscreen="1" allow="autoplay; encrypted-media" title="YouTube video player" width="720" height="405">
Also the comment from here is not up to date anymore.
For the rel option, the documentation currently says:
This parameter indicates whether the player should show related videos when playback of the initial video ends.
So this too doesn't apply when the video is paused.
YouTube deprecated parameter showinfo (can no more hide title) and changed parameter rel behavior (will show related videos).
Details in https://developers.google.com/youtube/player_parameters#release_notes_08_23_2018
Note: This is a deprecation announcement for the showinfo parameter. In addition, the behavior for the rel parameter is changing. Titles, channel information, and related videos are an important part of YouTube’s core user experience, and these changes help to make the YouTube viewing experience consistent across different platforms.

How to use alt image on iframe tag?

I am using iframe tag as below on my structure and template with webcontent, our business requirement is if video is not available on given link show alter image instead, I thought it should be easy and but after googling on it did not see any better way so thought let me ask here... any idea ?
here is my code looks like
<iframe src="${.vars['Embed_Link'].getData()}" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
Btw this is Liferay 6.2 EE
there is no alt image in an iframe. An iframe just shows whatever it finds under the URL that you provide to it, indiscriminately.
To mimic something like this: If the website (with the video) that you embed is under your control, you can determine what to show in case no video is available. Currently it might show a 404 error message, a search for related content, an ad, nothing at all.
Another way to mimic is: Find out if the server delivers 404 if a video is not available, then determine (using an Ajax-request) if you'll get 404 or 200 as response code. And only if you get 200, render the iframe, otherwise render your alternative image.
In general, this is quite unrelated to Liferay, and with this hints you might find some code in the regular web development circles

Still Possible to set Shuffle Settings on Iframe Embed Code?

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.

iframe API seems to only work on older vanity URLS

I have searched high and low and am unable to find a solution. It appears to me that the iframe API only works on older style URLs and not the newer customs ones.
What I mean is if a person has a YouTube URL of www.youtube.com/user/THEIR_NAME the iframe API works perfectly. However if they have www.youtube.com/c/THEIR_NAME the iframe API doesn't work.
Specifically I should say that individual video's work fine across all types - mostly because an individual video you add in the ID type for the specific video.
Examples of what I mean, if you add this (note I'll use a well known YouTuber with the older style URL). This works perfectly, the code is designed to find and display the latest uploaded video by the user using the listType=user_uploads and the list-USERNAME
<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed?autoplay=0&showinfo=0&rel=0&listType=user_uploads&list=pewdiepie" frameborder="0"/>
The above work exactly as I hoped. Now when I try it on a user that has the newer vanity URL of youtube.com/c/USERNAME I get a black screen in place of the video and on pressing the play button it says "An error occurred please try again later". This happens regardless of who I put in the list= field. If they have the new style /c/USERNAME address the video won't show up. Individual videos will show up from that user if listed though.
Example, same code as above but with a user that has the newer /c/USERNAME URL.
<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed?autoplay=0&showinfo=0&rel=0&listType=user_uploads&list=poziix" frameborder="0"/>
From the same user if I did the following code (below) it displays the video perfectly and as expected, again because it's using the video ID instead of the user channel name.
<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/HMP35vpPn6w?autoplay=0&showinfo=0&rel=0" frameborder="0"/>
I have tried this with a number of users that have the newer vanity URL of /c/USERNAME. I have also tried to use the actual name instead of the vanity for example I tried replacing "poziix" with "UCU0E_r2fyLxDQhhdLYcJrNA" the actual name and again no luck. I have also tried the name and actual name of another user with the /c/USERNAME with no luck.
Can someone advise on how I can go about fixing this? I am making a web site that is to display the latest uploaded video as it changes, and to date I've running into a brick wall.
Thank you kindly in advance.
Was having this exact same issue with the exact same use scenario.
Here's what I found... Go to the user's channel, all uploads, and then take the section of the url after '/channel/' which from what I can tell always starts with 'UC' on the newer channels. Use this, and change the first two letters from 'UC' to 'UU'
https://www.youtube.com/embed/videoseries?list=[UU.....]
I can't find any mention of videoserieson the iFrame Player API.

Resources