mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
@@ -0,0 +1,10 @@
|
||||
---
|
||||
import HtmlDemo from '@/components/docs/demos/HtmlDemo.astro';
|
||||
import html from './BasicUsage.html?raw';
|
||||
import './BasicUsage.css';
|
||||
---
|
||||
|
||||
<HtmlDemo html={html} />
|
||||
<script>
|
||||
import './BasicUsage.ts';
|
||||
</script>
|
||||
@@ -0,0 +1,52 @@
|
||||
.poster-basic {
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.poster-basic video {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.poster-basic__poster {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.25s;
|
||||
}
|
||||
|
||||
.poster-basic__poster:not([data-visible]) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.poster-basic__poster img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.poster-basic__button {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
padding-block: 8px;
|
||||
background: rgba(255, 255, 255, 0.75);
|
||||
backdrop-filter: blur(10px);
|
||||
color: black;
|
||||
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||
border-radius: 9999px;
|
||||
padding-inline: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.poster-basic__button .show-when-paused,
|
||||
.poster-basic__button .show-when-playing {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.poster-basic__button[data-paused] .show-when-paused {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.poster-basic__button:not([data-paused]) .show-when-playing {
|
||||
display: inline;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<video-player class="poster-basic">
|
||||
<video
|
||||
src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4"
|
||||
playsinline
|
||||
></video>
|
||||
|
||||
<media-poster class="poster-basic__poster">
|
||||
<img
|
||||
src="https://image.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/thumbnail.jpg"
|
||||
/>
|
||||
</media-poster>
|
||||
|
||||
<media-play-button class="poster-basic__button">
|
||||
<span class="show-when-paused">Play</span>
|
||||
<span class="show-when-playing">Pause</span>
|
||||
</media-play-button>
|
||||
</video-player>
|
||||
@@ -0,0 +1,3 @@
|
||||
import '@videojs/html/video/player';
|
||||
import '@videojs/html/ui/play-button';
|
||||
import '@videojs/html/ui/poster';
|
||||
@@ -0,0 +1,35 @@
|
||||
.poster-basic {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.poster-basic video {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.poster-basic__poster {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.25s;
|
||||
}
|
||||
|
||||
.poster-basic__poster:not([data-visible]) {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.poster-basic__button {
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
left: 10px;
|
||||
padding-block: 8px;
|
||||
background: rgba(255, 255, 255, 0.75);
|
||||
backdrop-filter: blur(10px);
|
||||
color: black;
|
||||
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||
border-radius: 9999px;
|
||||
padding-inline: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { createPlayer, features, PlayButton, Poster, Video } from '@videojs/react';
|
||||
|
||||
import './BasicUsage.css';
|
||||
|
||||
const Player = createPlayer({ features: [...features.video] });
|
||||
|
||||
export default function BasicUsage() {
|
||||
return (
|
||||
<Player.Provider>
|
||||
<Player.Container className="poster-basic">
|
||||
<Video src="https://stream.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/highest.mp4" playsInline />
|
||||
|
||||
<Poster
|
||||
className="poster-basic__poster"
|
||||
src="https://image.mux.com/lhnU49l1VGi3zrTAZhDm9LUUxSjpaPW9BL4jY25Kwo4/thumbnail.jpg"
|
||||
/>
|
||||
|
||||
<PlayButton
|
||||
className="poster-basic__button"
|
||||
render={(props, state) => <button {...props}>{state.paused ? 'Play' : 'Pause'}</button>}
|
||||
/>
|
||||
</Player.Container>
|
||||
</Player.Provider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: Poster
|
||||
frameworkTitle:
|
||||
html: media-poster
|
||||
description: Poster image component that stays visible until playback starts
|
||||
---
|
||||
|
||||
import ApiReference from "@/components/docs/api-reference/ApiReference.astro";
|
||||
import FrameworkCase from "@/components/docs/FrameworkCase.astro";
|
||||
import StyleCase from "@/components/docs/StyleCase.astro";
|
||||
import Demo from "@/components/docs/demos/Demo.astro";
|
||||
|
||||
{/* React demos */}
|
||||
import BasicUsageDemoReact from "@/components/docs/demos/poster/react/css/BasicUsage";
|
||||
import basicUsageReactTsx from "@/components/docs/demos/poster/react/css/BasicUsage.tsx?raw";
|
||||
import basicUsageReactCss from "@/components/docs/demos/poster/react/css/BasicUsage.css?raw";
|
||||
|
||||
{/* HTML demos */}
|
||||
import BasicUsageDemoHtml from "@/components/docs/demos/poster/html/css/BasicUsage.astro";
|
||||
import basicUsageHtml from "@/components/docs/demos/poster/html/css/BasicUsage.html?raw";
|
||||
import basicUsageHtmlCss from "@/components/docs/demos/poster/html/css/BasicUsage.css?raw";
|
||||
import basicUsageHtmlTs from "@/components/docs/demos/poster/html/css/BasicUsage.ts?raw";
|
||||
|
||||
## Anatomy
|
||||
|
||||
Import the component:
|
||||
|
||||
<FrameworkCase frameworks={["react"]}>
|
||||
```tsx
|
||||
<Poster src="poster.jpg" alt="Video preview" />
|
||||
```
|
||||
</FrameworkCase>
|
||||
|
||||
<FrameworkCase frameworks={["html"]}>
|
||||
```html
|
||||
<media-poster>
|
||||
<img src="poster.jpg" alt="Video preview" />
|
||||
</media-poster>
|
||||
```
|
||||
</FrameworkCase>
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
<FrameworkCase frameworks={["react"]}>
|
||||
<StyleCase styles={["css"]}>
|
||||
<Demo
|
||||
files={[
|
||||
{ title: "App.tsx", code: basicUsageReactTsx, lang: "tsx" },
|
||||
{ title: "App.css", code: basicUsageReactCss, lang: "css" },
|
||||
]}
|
||||
>
|
||||
<BasicUsageDemoReact client:idle />
|
||||
</Demo>
|
||||
</StyleCase>
|
||||
</FrameworkCase>
|
||||
|
||||
<FrameworkCase frameworks={["html"]}>
|
||||
<StyleCase styles={["css"]}>
|
||||
<Demo
|
||||
files={[
|
||||
{ title: "index.html", code: basicUsageHtml, lang: "html" },
|
||||
{ title: "index.css", code: basicUsageHtmlCss, lang: "css" },
|
||||
{ title: "index.ts", code: basicUsageHtmlTs, lang: "ts" },
|
||||
]}
|
||||
>
|
||||
<BasicUsageDemoHtml />
|
||||
</Demo>
|
||||
</StyleCase>
|
||||
</FrameworkCase>
|
||||
|
||||
<ApiReference component="Poster" />
|
||||
@@ -29,6 +29,7 @@ export const sidebar: Sidebar = [
|
||||
{ slug: 'reference/fullscreen-button' },
|
||||
{ slug: 'reference/mute-button' },
|
||||
{ slug: 'reference/play-button' },
|
||||
{ slug: 'reference/poster' },
|
||||
{ slug: 'reference/time' },
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user