sanity-io / sanity-mux-player

Play videos in the frontend uploaded with the MUX Sanity plugin
https://github.com/sanity-io/sanity-plugin-mux-input
21 stars 5 forks source link

[RFC] forwardRef as to expose the underlying <video> for custom behaviors #2

Open tomsseisums opened 5 years ago

tomsseisums commented 5 years ago

What you think of exposing the underlying <video> with a forwardRef?

One could then hook into various API's to set up custom systems, including custom controls.

tomsseisums commented 5 years ago

Hmm, if I understood correctly, it's possible to get a ref to SanityMuxPlayer and then call getVideoElement to get the actual video reference.

I wonder, should forwardRef still be implemented or the current way is sufficient?

skogsmaskin commented 5 years ago

Yes, you can access the video element with .getVideoElement.

Using forwardRef could be nice as well!

dictions commented 3 years ago

@tomsseisums @skogsmaskin how can you call a class method on a rendered React Element?

The only work around I've found is to create a ref wrapping the video player, and then do ref.current.querySelector('video').

Not elegant but it works!