Play multiple videos simultaneously

  1. Are you running your app locally or is it deployed? locally
  2. If your app is deployed:
    a. Is it deployed on Community Cloud or another hosting platform? No
    b. Share the link to the public deployed app. N/A
  3. Share the link to your app’s public GitHub repository (including a requirements file). N/A (closed-source)
  4. Share the full text of the error message (not a screenshot). N/A
  5. Share the Streamlit and Python versions. streamlit==1.30, Python 3.10.12

There was a topic posted a few years ago about playing multiple videos simultaneously, but it looks like that topic was closed:

Are there any plans to support this in the future? Even adding an additional button that will trigger the “play” button on all videos would suffice for my use case. Thanks!

How about:
two_videos_simultaneousgif

import streamlit as st

cols = st.columns(2)

with cols[0]: st.video("star.mp4")
with cols[1]: st.video("star.mp4")  

if st.button("Play all videos", use_container_width=True):
    st.components.v1.html(
        """<script>
        let videos = parent.document.querySelectorAll("video");
        videos.forEach(v => {
            v.play();
        })
        </script>""", 
        width=0, height=0
    )

They are not perfectly synchronized but it does the job of pressing play for all of them.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.