Does mux-video-react package offer programmatic play and pause of the video? #680
-
Does mux-video-react offer programmatic play and pause of the video? I could not locate any props or methods in the mux-video-react documentation. Kindly help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
mux-video-react doesn't offer something directly for that. You're expected to get the reference to the media element and then call play or pause on that. We have an example https://github.com/muxinc/elements/blob/main/examples/nextjs-with-typescript/pages/MuxVideo.tsx, which shows how to get the ref. I just submitted a PR to update the example to also use the ref to toggle playback via a checkbox: #681. You can see a preview of it here https://elements-demo-nextjs-git-fork-gkatsev-muxvideo-example-mux.vercel.app/MuxVideo Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
@gkatsev Thank you very much. This helps a lot :) Just checking if there is a method to programmatically restart the video from the start? |
Beta Was this translation helpful? Give feedback.
mux-video-react doesn't offer something directly for that. You're expected to get the reference to the media element and then call play or pause on that.
We have an example https://github.com/muxinc/elements/blob/main/examples/nextjs-with-typescript/pages/MuxVideo.tsx, which shows how to get the ref. I just submitted a PR to update the example to also use the ref to toggle playback via a checkbox: #681. You can see a preview of it here https://elements-demo-nextjs-git-fork-gkatsev-muxvideo-example-mux.vercel.app/MuxVideo
Hope this helps.