Skip to content
  • Android
  • iOS
  • Web

Video Player

Play a video with the engine player and optional playback controls.

Examples

Quick start

nayan-ui/video
import { VideoPlayer } from 'nayan-ui/video';

export function Clip({ uri }: { uri: string }) {
  return <VideoPlayer source={uri} controls contentFit="contain" style={{ height: 240 }} />;
}

Preview a muted looping clip

nayan-ui/video
import { VideoPlayer } from 'nayan-ui/video';

export function LoopPreview({ uri }: { uri: string }) {
  return <VideoPlayer source={{ uri, mimeType: 'video/mp4' }} autoPlay loop muted contentFit="cover" style={{ height: 180 }} />;
}

Control playback from your own buttons

nayan-ui/video
import { useRef } from 'react';
import { NButton } from 'nayan-ui/components';
import { VideoPlayer, type VideoPlayerHandle } from 'nayan-ui/video';

export function ControlledClip({ uri }: { uri: string }) {
  const player = useRef<VideoPlayerHandle>(null);
  return (
    <>
      <VideoPlayer ref={player} source={uri} controls={false} style={{ height: 240 }} />
      <NButton onPress={() => player.current?.play()}>Play</NButton>
      <NButton onPress={() => player.current?.pause()}>Pause</NButton>
      <NButton onPress={() => player.current?.seek(0)}>Restart</NButton>
    </>
  );
}

Tags