The LitPlayerYoutube is a video player based on YouTube built with Lit, which uses the official YouTube API to control the video. It is lightweight, customizable, and easy to use both as a pure Web Component and via React with the official wrapper.
To use the component, you need to install it via npm.
npm install lit-player-youtube
LIT:
import {LitPlayerYoutube} from "lit-player-youtube"
REACT:
import {LitPlayerYoutubeReact} from "lit-player-youtube"
Or in this way:
import "lit-player-youtube"
It was designed for rendering video easily, without needing to instantiate a class or call a method, just by importing the component and placing its tag.
<lit-youtube-player video="https://www.youtube.com/watch?v=tPBbeszlIXw"></lit-youtube-player>
<LitPlayerYoutubeReact video="https://www.youtube.com/watch?v=tPBbeszlIXw" />
To control its width and height, just place it inside a div or similar element and set the dimensions; the component is set to 100% width and height by default.
<div style="width: 600px; height: 350px">
<lit-youtube-player video="https://www.youtube.com/watch?v=tPBbeszlIXw"></lit-youtube-player>
</div>
Result: