Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 1

Code Block: How can I autoplay a video?


Mike T

Question

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

22 answers to this question

Recommended Posts

  • 2

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
  • 2

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 Ippolito, founder at squarekicker.com SquareKicker is a No-Code Design & Animation Extension for Squarespace. Say goodbye to copy & paste plugins and unlock your creativity and explore a whole new level of the unlimited design possibilities without ever having to write a single line of code.

Link to comment
  • 0

I know what you mean about auto starting. I tried inserting the code and it does not seem to work; I even tried copy and pasting the entire line of code above no luck there either (it plays ok, but not automatically). I'll keep trying ..

Link to comment
  • 0

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
  • 0

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
  • 0

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
  • 0

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
  • 0

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
  • 0

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
  • 0
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

Create an account or sign in to comment

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

×
×
  • Create New...