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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user