user10629012
user10629012

Reputation: 309

If body has fullpagejs class play video youtube api

I am using Fullpage.js and my first slide has a youtube video that autoplays using youtube embedded api. When I scroll to the next slide I have noticed that the video stops playing, I would like it to continue.

I am trying to check if the body has the class "fp-viewing-home" which is generated by fullpage.js when the first slide is active. Then if body has class play video.

var body = document.getElementsByTagName("body")[0];
var homeSlide = document.getElementsByClassName("fp-viewing-home")[0];

function hasClass(body, homeSlide) {
    event.target.playVideo();
}

I would like if the first slide in displaying the video to continue to play, else pause video

Upvotes: 0

Views: 330

Answers (1)

Alvaro
Alvaro

Reputation: 41595

According to fullpage.js documentation:

Pause on leave Embedded HTML5 / and Youtube iframes are automatically paused when you navigate away from a section or slide. This can be disabled by using the attribute data-keepplaying. For example:

<audio data-keepplaying>
    <source src="http://metakoncept.hr/horse.ogg" type="audio/ogg">
</audio>

Upvotes: 1

Related Questions