admin管理员组

文章数量:1125904

By default, Vidstack zooms/crops a vertical YouTube video into a 16/9 aspect ratio:

If the height: 1000% styling is disabled, the vertical video is contained as desired. However, unwanted elements like the "more videos" UI are added when the video is paused.

Is there a way to both contain the vertical video in a 16/9 frame and hide the "more videos" UI?

The player should support both vertical and horizontal videos so hard-coding the width and height in CSS is not acceptable. However, dynamically setting the width and height based on the video is acceptable (if this information is available).

If the following CSS is added, the vertical video fits, but I am unable to reduce the height of the player (to the same height as a 16/9 video) without introducing cropping/zooming.

media-player {
    aspect-ratio: 9/16;
}

The screen captures above used this minimal source code:

<html>
    <head>
        <link rel="stylesheet" href=".css" />
        <link rel="stylesheet" href=".css" />
    </head>

    <script src="; type="module"></script>

    <media-player src="youtube/IF_7SLHdreQ">
        <media-provider></media-provider>
        <media-video-layout></media-video-layout>
    </media-player>
</html>

References:

本文标签: htmlHow to contain vertical YouTube video in Vidstack (without quotmore videosquot UI)Stack Overflow