Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
115
rated 0 times [  116] [ 1]  / answers: 1 / hits: 27332  / 10 Years ago, thu, august 21, 2014, 12:00:00

my HTML5 video autoplay is not working.



<video preload=auto autoplay=true loop=loop muted=muted volume=0 id=myVideo>


I also tried without the =true value, and it doesn't work either. I've already used the same code in other sites and it worked just fine.



I'm using a framework based on fullPage.js, but i looked for something related on the files and didn't find anything.



The site is at http://agenciamilk.com/site/2/ if you wanna take a look. Thanks


More From » html

 Answers
10

You should use the afterRender callback the fullpage.js plugin offers.




afterRender()

This callback is fired just after the structure of the page is generated. This is the callback you want to use to initialize other plugins or fire any code which requires the document to be ready (as this plugin modifies the DOM to create the resulting structure).




You can take a look at a live example here or you can even find it in the examples folder of the fullpage.js download.



And you can easily see the source code its using:



$(document).ready(function () {
$('#fullpage').fullpage({
verticalCentered: true,
sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE'],
afterRender: function () {

//playing the video
$('video').get(0).play();
}
});
});


UPDATE



This is no longer necessary in fullpage.js > 2.6.6.
It will automatically play the video when accessing the section as far as it has the tag autoplay in it:



<video autoplay loop muted controls=false id=myVideo>
<source src=imgs/flowers.mp4 type=video/mp4>
<source src=imgs/flowers.webm type=video/webm>
</video>


In case you only want to play it on section load (not on page load) use data-autoplay.
More info at the documentation.


[#69699] Tuesday, August 19, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
saulthomasb

Total Points: 326
Total Questions: 98
Total Answers: 93

Location: Jordan
Member since Sun, Dec 26, 2021
2 Years ago
;