VideoRef
A Video's ref that also holds its state: signals for what the player is
doing, and time and duration as motion values. Between the player's
reports the UI thread moves time along at the player's rate, so a bound
progress bar needs no onProgress. Called while a component sets up, which
owns it, like ref(), and passed as the view's ref.
Utilização
Seek a lesson video back to the beginning.
Este tipo é usado por videoRef
// Seek a lesson video back to the beginning.
import { Button, Video, VStack, videoRef } from 'kuito';
export function Lesson() {
const player = videoRef();
return (
<VStack flex={1}>
<Video ref={player} src={{ uri: 'https://example.com/lesson.mp4' }} height={240} controls />
<Button onPress={() => void player.current?.seek(0).catch(console.error)}>
Restart lesson
</Button>
</VStack>
);
}Declaração do tipo
export type VideoRef = ElementRef<VideoHandle> & {
readonly playing: ReadonlySignal<boolean>;
readonly loaded: ReadonlySignal<boolean>;
readonly buffering: ReadonlySignal<boolean>;
readonly fullscreen: ReadonlySignal<boolean>;
readonly pictureInPicture: ReadonlySignal<boolean>;
readonly error: ReadonlySignal<string | null>;
/** Seconds from the start. */
readonly time: Motion<number>;
/** Seconds; 0 until loaded, and for a live stream. */
readonly duration: Motion<number>;
/** Calls `listener` each time playback reaches the end. */
watch(event: 'ended', listener: () => void): EventSubscription;
};Membros 10
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
current | VideoHandle | Sim | — |
playingsó de leitura | ReadonlySignal<boolean> | Sim | — |
loadedsó de leitura | ReadonlySignal<boolean> | Sim | — |
bufferingsó de leitura | ReadonlySignal<boolean> | Sim | — |
fullscreensó de leitura | ReadonlySignal<boolean> | Sim | — |
pictureInPicturesó de leitura | ReadonlySignal<boolean> | Sim | — |
errorsó de leitura | ReadonlySignal<string> | Sim | — |
timesó de leitura | Motion<number> | Sim | Seconds from the start. |
durationsó de leitura | Motion<number> | Sim | Seconds; 0 until loaded, and for a live stream. |
watch | (event: "ended", listener: () => void) => EventSubscription | Sim | Calls listener each time playback reaches the end. |
watch — assinaturas de método
Assinaturas
(event: "ended", listener: () => void): EventSubscriptionParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
event | "ended" | Sim | — |
listener | () => void | Sim | — |
Devolve
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.