Random Video Backgrounds on Homepage
-
Hey spontanus
<video data-ar="0.75" preload="http://82.80.209.62/~cleanpla/sasha2017/videobg/3.mp4" muted="" autoplay="" loop=""><source src="http://82.80.209.62/~cleanpla/sasha2017/videobg/3.mp4" type="video/mp4"></video>
Not sure if preload="yoururl" is valid html. Maybe try just preload without ="yoururl"
-
-
No, just remove this line from your javascript:
$('video').attr('preload', videopath);
Maybe that helps!
-
@spontans said in Random Video Backgrounds on Homepage:
Frontend.GlobalEvents.on("newpageshown", function(layoutObj, type, obj)
hi/
how will you approach this in 2020 ?
i want to have the same , a script the randomly loads a video for the background page.
the page i'm working on is http://telegraf.studio /
thank you / -
-
hey @mariusjopen ~ thanks for replying
i'm a total noob when it comes to web / wordpress environment , so please excuse if i'm missing something obvious .
so what i understand from @spontans code , applied to my project is thisif($("body").hasClass("slug-welcome")) {
var videosrc = Math.floor(Math.random() * 2) + 1;
var homeurl = 'http://telegraf.studio/wp-content/uploads/2020/02/'';
videopath = homeurl+videosrc+'.mp4';
$('video source').attr('src', videopath);
}i've modified the slug-home2 on the first line to my page name : slug-welcome
the math.floor is modified from 6 to 2 , in my case i would like to have just 2 movies in the folder
the path is also changed to my media folder that contains the movies.should i also modify $ to JQuery ?
where do i place this code ? i've read about custom css/html , but just adding this to custom html head dose not
work .thanks
-
Dear @silviu
should i also modify $ to JQuery ?
This is correct.http://laytheme.com/documentation.html#custom-javascript
Try that!
Best!
Marius
-
@silviu said in Random Video Backgrounds on Homepage:
hey @mariusjopen ~ thanks for replying
i'm a total noob when it comes to web / wordpress environment , so please excuse if i'm missing something obvious .
so what i understand from @spontans code , applied to my project is thisif($("body").hasClass("slug-welcome")) {
var videosrc = Math.floor(Math.random() * 2) + 1;
var homeurl = 'http://telegraf.studio/wp-content/uploads/2020/02/'';
videopath = homeurl+videosrc+'.mp4';
$('video source').attr('src', videopath);
}i've modified the slug-home2 on the first line to my page name : slug-welcome
the math.floor is modified from 6 to 2 , in my case i would like to have just 2 movies in the folder
the path is also changed to my media folder that contains the movies.should i also modify $ to JQuery ?
where do i place this code ? i've read about custom css/html , but just adding this to custom html head dose not
work .thanks
Hey Silviu
Did you solve it?I'm trying to get the above to work, but it seems like I'm missing something.
<script>
Frontend.GlobalEvents.on("newpageshown", function(layoutObj, type, obj) {
if(JQuery("body").hasClass("slug-home")) {
var videosrc = Math.floor(Math.random() * 3) + 1;
var homeurl = 'http://hidden.com/wp-content/uploads/'2020/09/';
videopath = homeurl+videosrc+'.mp4';
JQuery('video source').attr('src', videopath);
}
});
</script>Best,
Christian
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it