Skip to content

Comments

fix: wrong youtube iframe height#1481

Closed
jramke wants to merge 1 commit intovidstack:mainfrom
jramke:patch-1
Closed

fix: wrong youtube iframe height#1481
jramke wants to merge 1 commit intovidstack:mainfrom
jramke:patch-1

Conversation

@jramke
Copy link
Contributor

@jramke jramke commented Oct 24, 2024

Related:

/

Description:

The iframe height was set to 1000% instead of 100% wich resulted in a cropped and pixelated preview image.

Ready?

yes

Anything Else?

/

Review Process:

/

@mihar-22
Copy link
Member

The height is set on purpose to prevent YouTube branding from showing up. Use the poster component to address the pixelated issue as shown in the docs:

React:

<MediaPlayer>
  <MediaProvider>
    <Poster className="vds-poster" />
  </MediaProvider>
</MediaPlayer>

HTML:

<media-player>
  <media-provider>
    <media-poster class="vds-poster" />
  </media-provider>
</media-player>

@mihar-22 mihar-22 closed this Oct 24, 2024
@jramke
Copy link
Contributor Author

jramke commented Oct 24, 2024

Oh, well thanks for the hint.

Yep when setting a poster source the media-poster element is correctly created.
For my use case i will fetch the youtube video thumbnail as fallback then.

Maybe its worth to implement from vidstack by default
https://stackoverflow.com/questions/2068344/how-do-i-get-a-youtube-video-thumbnail-from-the-youtube-api

Best regards

@mihar-22
Copy link
Member

No source is required when using the YouTube provider, the poster should work as expected. The above examples assume you're using the Default Theme and you've applied the vds-poster class.

@jramke
Copy link
Contributor Author

jramke commented Oct 24, 2024

Im using the normal js api so i can progressively enhance the browsers video element or in this case iframe.

When the player is created form the iframe the aspect ratio gets set to unset. And the element will be just 150px in height.
If the media-players aspect ratio is set to 16 / 9 via css with !important the preview image is pixelated and cropped.
Here is a repro link: https://stackblitz.com/edit/vitejs-vite-m2eptd?file=main.js

PS: i tried to include the web components element as reference but i somehow couldn't get it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants