0

I have installed Reactplayer package in my Next.js application where i tried to load the vimeo video. but during the initial render the player seems to be small and then it expands like the one in the screenshot.

Initial enter image description here

After render enter image description here

Here is the below snippet where i have used React player to be responsive

Wrapper


<div className="relative w-[100%] mobile:w-[70%] pt-[56.25%] mobile:pt-[40%] bg-gold-label-pastel">
  <div>
    <ReactPlayer
      className="react-player"
      width="100%"
      height="100%"
      url="https://player.vimeo.com/video/786201103"
      controls={true}/>
   </div>
 </div>

CSS

.react-player {
  position: absolute;
  top: 0;
  left: 0;
}
Nidhin Kumar
  • 3,278
  • 9
  • 40
  • 72

2 Answers2

0

Try removing the div that surrounds the actual player like this...

 <div className="relative w-[100%] mobile:w-[70%] pt-[56.25%] mobile:pt-[40%] bg-gold-label-pastel">
    <ReactPlayer
      className="react-player"
      width="100%"
      height="100%"
      url="https://player.vimeo.com/video/786201103"
      controls={true}
     />
 </div>
0

This seems to be a bug in the Vimeo API mentioned here: https://github.com/CookPete/react-player/issues/810#issuecomment-604110350

In my case, I was able to resolve the issue by removing width="100%" and height="100%" from <ReactPlayer/> parameters and applying following CSS:

.react-player {
  width: 100% !important;
  height: 100% !important;
}

.react-player iframe {
  width: 100%;
  height: 100%;
}
Nashi
  • 76
  • 6