VideoPlayer
Genel görünümimport { VideoPlayer, VideoPlayerLabels, VideoRatio } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Temel
Gerçek bir video öğesinin üzerinde özel denetimler. Tanınmayan her şey medya öğesine yayılır; böylece preload, crossOrigin ve medya olayları bu bileşen onları yeniden bildirmeden çalışır — className istisnadır, kapsayıcıyı biçimlendirir.
import { VideoPlayer } from "@nili/ui"
export function Example() {
return (
<VideoPlayer
src="/media/flower.mp4"
poster="/media/flower.jpg"
labels={{
root: "Product tour",
play: "Play",
pause: "Pause",
seek: "Seek",
fullscreen: "Full screen",
}}
/>
)
}En boy oranları
Çerçeveyi dosya değil ratio belirler — böylece üstveri geldiğinde yerleşim zıplamaz. auto kutuyu videonun kendi boyutlarına bırakır.
import { VideoPlayer } from "@nili/ui"
export function Example() {
return (
<>
<VideoPlayer src={src} ratio="16/9" />
<VideoPlayer src={src} ratio="4/3" />
<VideoPlayer src={src} ratio="1/1" />
<VideoPlayer src={src} ratio="auto" />
</>
)
}Denetim yoğunluğu
size videonun değil denetimlerin boyutunu belirler. Oynatıcı bir kartta ya da kenar çubuğunda dururken ve tam boy çubuk çerçeveyi kalabalıklaştırırken sm kullanın.
import { VideoPlayer } from "@nili/ui"
export function Example() {
return (
<>
<VideoPlayer src={src} size="md" />
<VideoPlayer src={src} size="sm" />
</>
)
}Altyazılar, otomatik oynatma ve yerel denetimler
tracks altyazılar için track öğeleri alır — onları ekleyin; sessiz otomatik oynayan bir video onlarsız okunmaz. Otomatik oynatma her tarayıcıda yalnızca sessizken çalışır, bu yüzden ikisi birlikte gider. nativeControls, resim içinde resim ve yayın menülerine ihtiyaç duyduğunuzda çubuğu tarayıcıya geri verir.
import { VideoPlayer } from "@nili/ui"
export function Example() {
return (
<>
<VideoPlayer
src={src}
tracks={
<track
kind="captions"
srcLang="en"
label="English"
src="/media/flower.en.vtt"
default
/>
}
/>
{/* muted autoplay, looping — a background clip */}
<VideoPlayer src={src} autoPlay loop muted />
{/* the browser's own controls */}
<VideoPlayer src={src} nativeControls />
</>
)
}Olaylar ve ileri sarma
onPlayChange ve onTimeChange analitik ve bir dökümü eşitlemek içindir. seekStep ok tuşlarının ne kadar atlayacağını belirler — varsayılan beş saniyedir ve uzun bir ders genelde daha fazlasını ister.
import { VideoPlayer } from "@nili/ui"
export function Example() {
return (
<VideoPlayer
src={src}
seekStep={10}
onPlayChange={(playing) => track(playing ? "play" : "pause")}
onTimeChange={(time) => syncTranscript(time)}
/>
)
}VideoButton
dahiliVideoControls
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| visible | 'true' | 'false' | true |
VideoElement
dahiliVideoOverlayButton
dahiliVideoPlayer
extends Omit< ComponentPropsWithoutRef<'video'>, 'src' | 'poster' | 'controls' | 'children' | 'autoPlay' | 'loop' | 'muted' >
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | md | sm | md | |
| ratio | 16/9 | 4/3 | 1/1 | auto | 16/9 |
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| src* | string | — | |
| poster | string | — | |
| tracks | ReactNode | — | Caption and subtitle tracks. Pass real `<track>` elements — captions are the accessibility story of this component, not an optional extra. |
| autoPlay | boolean | false | |
| loop | boolean | false | |
| muted | boolean | false | Starts muted. Required by browsers for autoplay to be allowed at all. |
| nativeControls | boolean | false | Hand control back to the browser's own UI. Worth doing when the platform player is better than anything you would ship — picture-in-picture, AirPlay, and caption styling all come free with it. |
| seekStep | number | 5 | Seconds jumped by the arrow keys. |
| onPlayChange | (playing: boolean) => void | — | |
| onTimeChange | (currentTime: number) => void | — | |
| locale | string | — | BCP-47 tag driving the timestamps (`'fa'` → Persian). Defaults to the ambient locale from `NiliProvider`. |
| labels | VideoPlayerLabels | — |