Jump to content

Code Block: How can I autoplay a video?

Go to solution Solved by foleyatwork,

Recommended Posts

Hi. I have tried to embed code from both Vimeo and Youtube using their automatic startup code option (under share options) but when I run it it stills requires me to click the play button. Any ideas on how to do this would be appreciated, either Youtube or Vimeo is fine.

Edited by llogan
Link to comment
  • Solution

Disclaimer: I almost always think autostarting videos is a terrible idea. Just my personal opinion. Please do good, not evil, with this answer.

With YouTube you can just add ?autoplay=1 to the end of the iframe URL. For instance:


<iframe width="420" height="315" src="http://www.youtube.com/embed/4KRZQQ_eICo?autoplay=1" frameborder="0" allowfullscreen></iframe>

Edited by foleyatwork

Developer Evangelist at Squarespace.

Link to comment

I go to the video on Youtube, click on share, go to the embed option, cut and then in the Squarespace editing screen paste it into embed code (gear icon), then save. Maybe the Squarespace theme I have does not support that? I also tried just copying the code above and pasting it into the embed code window. The video works, just not automated. The link above autoplays for me when I go to it directly outside of Squarespace.

Link to comment
  • 1 year later...

Just thought I'd add a comment to share my recent experience. I had an iframe tag for embedding a video that is a countdown time to an upcoming event, and thus having the video play automatically is desirable.

Dropping the tag into a code block was not ideal, as the code block was not responsive to browser window changes. I was placing two videos side-by-side, so having them resize was important. One would resize, and the other would not.

I ended up discovering that I could use a video block while also dropping in the iframe tag I had been given. I clicked the gear icon to the right of the URL box. That opened an Edit Embedded Data dialog. I took a shot and pasted the iframe tag into that box, and that did the trick. Despite the iframe tag including a width and a height, the video resizes along with the browser screen, and I'm able to have my two videos side-by-side. One is a countdown timer that auto starts. The other is a video that the user must click to play.

Link to comment
  • 1 year later...
  • 4 weeks later...
  • 2 months later...
  • 4 months later...
  • 2 years later...

Hi @Mike T, I made a video tutorial for you on can autoplay a video. Hope this helps! https://www.askquesty.com/squarespace-answers/code-block-squarespace-tutorial

Have Squarespace questions/task and need help today? **You can hire us here.** Our answers are on-demand, video recorded, and only cost between $5 to $25. Estimates are free, 100% satisfaction guarantee, and trusted by hundreds of small businesses.

Link to comment
  • 3 weeks later...
  • 7 months later...
  • 6 months later...

Hi know this is an old post, but I thought I'd chime in.  I've manage to do this, and it pretty easy really.  

I'm using Vimeo, and I have used the below iframe inside Squarespace's video block, not a code block.  But instead of adding the link, you can click <>  and insert this code.  

I am using it on our new SquareKicker website for our learn page here:  https://squarekicker.com/learn

Just swap out the vimeo number for yours.  See screenshot below for example.

<iframe src="https://player.vimeo.com/video/466007910?autoplay=1&loop=1&autopause=0&background=1&color=ffffff&controls=0&portrait=0" width="800" height= "500"  frameborder="0" allow="autoplay; fullscreen"  allowfullscreen></iframe>

It also will auto play on mobile.  You can adjust the settings for controls back to 1 instead 0.  And muted is background=1, so if you want sound change that, switch it to 0.  

 

Autoplay Video Block.png

SquareKickerHi, I'm Nick, CEO & Co-Founder at squarekicker.com.  Take your Squarespace sites to the next level with SquareKicker's No-Code Design & Animation Extension. Break free from templates & complex code and start building unique websites that you are proud to show your clients without ever having to write a single line of code. 

Tutorials  ●  News  ●  Inspiration  ●  Features  ●  FAQS

 

Link to comment
  • 4 months later...

Hello. I had the same problem. I uploaded a video to Vimeo, I stopped using Youtube, Vimeo is just way easier to use for embedding video and has better quality playback.

I used a "video block" and entered the following code using the "embed data" feature in the video player settings:

<iframe src="https://player.vimeo.com/video/REPLACE WITH YOUR VIMEO CODE HERE?autoplay=1&loop=1&autopause=0&background=1&color=ffffff&controls=0&portrait=0" width="800" height= "500"  frameborder="0" allow="autoplay; fullscreen"  allowfullscreen></iframe>

I did change the width and height to what I needed, I recommend you do the same also.

This was posted by NickIppolito above. I can tell you it works on the Brine Template for 7.0 as thats what my site is built on. My video auto-plays and keeps looping which is what I needed. My video doesn't have any sound so I can't comment on that.

 

Edited by Skylab
Link to comment
  • 1 month later...

Vimeo has the code here: https://vimeo.zendesk.com/hc/en-us/articles/115004485728-Autoplaying-and-looping-embedded-videos

Here's the code they provide:

<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&autopause=0" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

I used a video block and opened up the brackets. Then dropped the code in and changed the video player link to my video (the numbers before the "?".

 

Link to comment
  • 2 weeks later...

Hi All, 

i have a intro video that i want displaying full bleed, with audio, autoplay and play on mobile. 

I have been speaking to support and they say 'This isnt possible on squarespace, you need custom code' i have no idea how to do this. 

currently i have added my video as a background video on my home page. This auto plays but no audio and it doesn't play on mobile. I have iphone 10 and fast internet. 

Please can someone help me, 99% of the website traffic will be mobile so i want the video to play. 

Thanks Adam

Link to comment
  • 3 months later...
On 3/30/2021 at 11:54 AM, whitney.revoir said:

Vimeo has the code here: https://vimeo.zendesk.com/hc/en-us/articles/115004485728-Autoplaying-and-looping-embedded-videos

Here's the code they provide:

<iframe src="https://player.vimeo.com/video/76979871?autoplay=1&loop=1&autopause=0" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

I used a video block and opened up the brackets. Then dropped the code in and changed the video player link to my video (the numbers before the "?".

 

Thank you for this, Whitney! 

Link to comment
  • 6 months later...

I made a video looping and autoplay, then wanted it to stop. I have tried every code everyone has listed here, and put '0' in place of the '1'. To no avail. 

The video used to need to autoplay and loop because it was just for visual effect. Now it has narration and I give the viewer the option to click on it. So the autoplay has stopped, but it continues again when complete. I am so frustrated. Vimeo can't even figure out a workaround. It must be on the Squarespace end. 

PLEASE HELP! @tuanphan or anyone who is listening.

This is the default embed code Vimeo has for the video. 

<div style="padding:56.25% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/661047520?h=310e582965&amp;badge=0&amp;autopause=0&amp;player_id=0&amp;app_id=58479" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen style="position:absolute;top:0;left:0;width:100%;height:100%;" title="PV_Legacy_IntroVideo.mov"></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>

Link to comment
On 2/11/2022 at 1:29 AM, jenartsquare said:

I made a video looping and autoplay, then wanted it to stop. I have tried every code everyone has listed here, and put '0' in place of the '1'. To no avail. 

The video used to need to autoplay and loop because it was just for visual effect. Now it has narration and I give the viewer the option to click on it. So the autoplay has stopped, but it continues again when complete. I am so frustrated. Vimeo can't even figure out a workaround. It must be on the Squarespace end. 

PLEASE HELP! @tuanphan or anyone who is listening.

This is the default embed code Vimeo has for the video. 

<div style="padding:56.25% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/661047520?h=310e582965&amp;badge=0&amp;autopause=0&amp;player_id=0&amp;app_id=58479" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen style="position:absolute;top:0;left:0;width:100%;height:100%;" title="PV_Legacy_IntroVideo.mov"></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>

Is this a background video, a video block, or a code block your using this? You can try instead of adding the entire iframe and script to just the Vimeo url to a video block. 

SquareKickerHi, I'm Nick, CEO & Co-Founder at squarekicker.com.  Take your Squarespace sites to the next level with SquareKicker's No-Code Design & Animation Extension. Break free from templates & complex code and start building unique websites that you are proud to show your clients without ever having to write a single line of code. 

Tutorials  ●  News  ●  Inspiration  ●  Features  ●  FAQS

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.