Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

share video accross multiple slides or fragements w/o restarting the video #2882

Closed
think-nice-things opened this issue Jan 24, 2021 · 5 comments

Comments

@think-nice-things
Copy link

think-nice-things commented Jan 24, 2021

Hi,

I just found that sharing a background video accross multiple slides or fragments restarts the video.
Is there a way to not restart the video but just keep it running?

Examples

share video accross multiple slides

If switching from the first to the second slide, the video restarts from the beginning.
I'd rather like to keep it running and not restarting it.

<section>
  <section data-background-video = "myvideo.mp4" data-background-video-loop> 
    content
  </section>
  <section data-background-video = "myvideo.mp4" data-background-video-loop> 
    content
  </section>
</section>

share video with fragments

If switching to the second fragment the video restarts from the beginning.
I'd rather like to keep it running and not restarting it.

<section data-background-video="myvideo.mp4" data-background-video-loop>
  <div>
    <h2>Some caption</h2>
  </div>
  <div class = 'fragment'>
    Text which appears as fragment later.
  </div>
</section>

any ideas?

@rben01
Copy link

rben01 commented Mar 1, 2024

I have what I believe is the same issue, but for ordinary videos, not background videos. When a ![](video.mp4) on a slide is playing, every fragment on the slide will restart the video. I'd expect the video to just continue playing through the fragments.

hakimel added a commit that referenced this issue Mar 8, 2024
@hakimel
Copy link
Owner

hakimel commented Mar 8, 2024

Multiple identical & consecutive background videos will now keep playing without interruption as of a29a9c7

I have not been able to reproduce the issue with fragments restarting videos so assuming that's already been fixed.

@hakimel hakimel closed this as completed Mar 8, 2024
@rben01
Copy link

rben01 commented Mar 8, 2024

Multiple identical & consecutive background videos will now keep playing without interruption as of a29a9c7

I have not been able to reproduce the issue with fragments restarting videos so assuming that's already been fixed.

I don't think so, on master there is this:

if( el.readyState > 1 ) {
this.startEmbeddedMedia( { target: el } );
}

I believe this runs unconditionally when a fragment is advanced, and causes all videos on the slide to restart.

@hakimel
Copy link
Owner

hakimel commented Mar 11, 2024

@rben01 The startEmbeddedMedia accepts different target elements and will only play media elements found in that scope. When stepping through slides, we call startEmbeddedMedia( slideElement ) which starts all media on the slide. But when going through fragments we invoke startEmbeddedMedia( fragmentElement ) so that only media inside of the newly shown fragment play.

I did noticed that videos were resetting when hiding fragments though, and perhaps there are other cases I've missed. I pushed a small change that should guard against resetting any video that is already playing:

1748a55#diff-bc5fdf2e5a37c0d28014f2a2d06dfe42bd43718f3aed85e434dcc5b66dcb7556R378-R382

@rben01
Copy link

rben01 commented Mar 13, 2024

Yes, this.startEmbeddedMedia( { target: el } ); only starts playing the targeted element, but it is called for every video on the page whenever startEmbeddedContent is called. So the check you introduced is necessary.

Separately, I'm not sure if restarting videos that have finished playing is the right call — I would imagine that some people would like them to play once and never restart. Could this be controlled with an attribute like data-allow-loop-on-fragment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants