Jump to content

Loading a random video banner on refresh

Recommended Posts

  • 3 weeks later...
On 2/18/2021 at 1:44 AM, elevation said:

It's a business plan.

 

On 2/22/2021 at 6:36 PM, olaastrand2 said:

hi,

im also very interested in this question. I want to load random embedded youtube content on my landingpage.

Hi. Sorry for the delay. You can use Code Block to create background. Thus, you can achieve this effect easily.

I search & found this effect. If you like this, I will test something to convert it to Code Block in Squarespace.

Link: https://codepen.io/team/rcrooks1969/pen/oENWJj

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 2 months later...

Trying the reference site you posted above... must be missing something.  On SS7.1 and would like to do the same.   Need to have a different video load behind the main code block on our website on each visit.  

Website for example is https://voyr.me 

 

Link to comment
On 5/10/2021 at 4:59 PM, dsiles said:

Trying the reference site you posted above... must be missing something.  On SS7.1 and would like to do the same.   Need to have a different video load behind the main code block on our website on each visit.  

Website for example is https://voyr.me

 

Which code did you add? Can you share link to page (your site) where you added code? We can check easier

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 5 weeks later...
  • 2 years later...

Hello!

I recently had the same question. On the homepage of a website of mine, I had a video background using a Vimeo link. I wanted that video to switch randomly with other Vimeo videos on refresh. I succeeded by using the script below, which you need to paste into the header section of code injection. Change the provisional videoIDs (000000001 and 000000002) with the videoIDs of the Vimeo videos you want to target, and feel free to add more after the comma. Under fallbackVideo, you can specify a fallback video in the same way.

Good luck.

 

<!-- VIDEO BACKGROUND -->

<script>
window.onload = function() {
var videoIDs = ['000000001', '000000002'];
var fallbackVideo = '000000000';
var randomID = videoIDs[Math.floor(Math.random() * videoIDs.length)];
var vimeoPlayer = document.getElementById('vimeoplayer');
vimeoPlayer.onerror = function() {
vimeoPlayer.src = '//player.vimeo.com/video/' + fallbackVideo + '?api=1&background=1';
}
vimeoPlayer.src = '//player.vimeo.com/video/' + randomID + '?api=1&background=1';
}
</script>

 

Link to comment
  • 2 months later...

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.