react-player
react-player copied to clipboard
[Feature Request] Callback on mounted video element.
I am using react-player
to render FilePlayer
and the native video
element.
I need to perform some CSS style computation when the video is ready but call to ref.getInternalPlayer()
returns null
.
I managed to achieve desired behavior using a workaround where I am performing computation on onReady
callback, but it would be very handful to have a dedicated callback executed once we have a video element in the DOM and we can access it with getInternalPlayer
method.
My current workflow is following
- Attach reference to the player.
- Wait for
onReady
callback. - Get internal video element
const videoElement = reactPlayer.getInternalPlayer();
- Get video client rect.
const rect = videoElement.getBoundingClientRect();
- perform computation...
Curious what computation you are referring to is? I am trying to do something similar with getting the position of the mouse click with regards to the video player.
I am calculating the parent element height since the video element is grouped with other building blocks.