html5 video with lazy loading

erel's Avatar

erel

14 Dec, 2021 03:59 PM

I want videos to autoplay.The recommendation is to use the standard video element directly. Will it load all videos at once? If so, is it possible to use the API to load the videos when the slide becomes active?

  1. Support Staff 1 Posted by Dmytro Semenov on 14 Dec, 2021 09:20 PM

    Dmytro Semenov's Avatar

    Hello,

    You may use events like rsAfterSlideChange (that triggers every time a slide is switched), or rsAfterContentSet (that triggers after slide content is added, for lazy-loaded slides too). And activate your videos there.

    For example:

    var slider = $('.royalSlider').data('royalSlider');
    slider.ev.on('rsAfterSlideChange', function() {
      console.log(slider.currSlide.content.get(0));
    });
    

    ... will give you the current slide element, and you may either dynamically create video element or play/pause it.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac