question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apply aspect ratio from video

See original GitHub issue

Related to #145: It would be nice if you could tell the player to use the native video aspect ratio.

Once the video is available, it seems that the readonly props videoHeight and videoWidth should be there, and then by measuring the ReactPlayer’s parent element dimensions, the <video> can be sized, or for smooth responsiveness the padding-top trick could be used to force a height if the width is a css-fixed value.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
seduboiscommented, Nov 21, 2017

Thanks for the quick reply! CSS is dark magic for me, but I got something working:

export default ({ url }) => (
  <div
    css={{
      display: `flex`,
      minHeight: `100vh`,
      background: `black`,
    }}
  >
    <div
      css={{
        width: `90%`,
        maxWidth: 1000,
        margin: `auto`,
      }}
    >
      <div
        css={{
          position: `relative`,
          paddingTop: `56.25%`,
        }}
      >
        <ReactPlayer
          url={url}
          width="100%"
          height="100%"
          css={{
            position: `absolute`,
            top: 0,
            left: 0,
          }}
        />
      </div>
    </div>
  </div>
)
1reaction
cookpetecommented, Nov 14, 2017

@jjperezaguinaga Yeah all React fiddles made from the old base fiddle (before react@16 came along) are now broken, as they’ve changed how the files work. The old React base jsFiddle used react-with-addons.js that now does not exist in v16.

Here’s an updated fiddle (note how the fileConfig is no longer necessary since https://github.com/CookPete/react-player/commit/b59d251b1323d97d2494bc4a7fd65a12905a4ba5).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quickly Change the Aspect Ratio of a Video (Easy Way)
To set an aspect ratio of your choice, simply click on the Custom Size button, enter the width and height of your video,...
Read more >
How to Change the Aspect Ratio of your Videos for Free?
Step 1: Open Animotica · Step 2: Change Your Aspect Ratio · Step 3: Apply Fit/Fill · Step 4. Save.
Read more >
Change aspect ratio of videos easily | Online and Fast - Flixier
Change the aspect ratio of your videos in a few clicks. Add videos to Flixier, set the project to your desired ratio and...
Read more >
How to change the aspect ratio of a video | Clipchamp Blog
To change the aspect ratio of your entire video, click on the 16:9 aspect ratio button located under the export button.
Read more >
7 Quick Ways to Change Video Aspect Ratio on Windows and ...
The fastest way to resize or change the aspect ratio of a video on Windows and Mac without losing quality is using VideoProc...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found