-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Responsive width
#145
Comments
You should be able to pass .wrapper {
position: relative;
padding-top: 56.25% /* Player ratio: 100 / (1280 / 720) */
}
.player {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
} <div className='wrapper'>
<ReactPlayer
className='player'
playing
url={...}
width='100%'
height='100%'
/>
</div> |
Also see example jsFiddle. |
Thanks! |
This would be very helpful to include in the README. |
Nearly a year late but it's finally in there: https://github.com/CookPete/react-player#responsive-player 😞 |
This does not work for vertical videos. Is there a solution where the padding-top is not static and it is calculated from the video dimension? |
@vicentel89 Same issue here ! |
It depends what type of video you are playing. If you are playing a raw video file, just set If you are playing something that uses an iframe (youtube, facebook etc), they have no knowledge of the aspect ratio of the video, so a dynamic aspect ratio is not possible. If you know the aspect ratio of your vertical video, this trick still works – just reverse the numbers. So the padding-top: 177.78% /* Player ratio: 100 / (720 / 1280) */` |
What if I wanted to make it responsive within a flexbox container with two columns? Is that possible with the above solution? |
If you know the aspect ratio, the |
everything you guys are saying is absolutely right but dont forget to add this line of code " ! important " ..wrapper { .player { |
👍 |
Hi,
Is it possible to make the
<ReactPlayer>
width
responsive?For example to inherit the width of the
div
ortd
in which is placed?Thanks
The text was updated successfully, but these errors were encountered: