{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "video",
  "title": "Video",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/video/Video.tsx",
      "content": "import * as React from 'react'\nimport { AppState, Platform, StyleSheet, View, type ViewProps } from 'react-native'\nimport {\n  VideoView,\n  useVideoPlayer,\n  type VideoSource,\n  type VideoPlayerStatus,\n  type PlayerError,\n  type VideoViewProps,\n} from 'expo-video'\nimport { Button } from '@/components/ui/button'\nimport { Spinner } from '@/components/ui/spinner'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nexport interface VideoHandle {\n  play: () => void\n  pause: () => void\n  replay: () => void\n  enterFullscreen: () => Promise<void>\n}\n\n/** Expo Modules must be configured in bare RN. Backgrounding pauses playback; returning never resumes it. */\nexport interface VideoProps extends Omit<ViewProps, 'children'> {\n  source: VideoSource\n  /** Set false when a retained route loses focus. Returning does not resume playback. */\n  active?: boolean\n  muted?: boolean\n  loop?: boolean\n  aspectRatio?: number\n  className?: string\n  fullscreenOptions?: NonNullable<VideoViewProps['fullscreenOptions']>\n  errorMessage?: string\n  retryLabel?: string\n  onStatusChange?: (status: VideoPlayerStatus, error?: PlayerError) => void\n  onPlayingChange?: (playing: boolean) => void\n}\n\nfunction hasSource(source: VideoSource) {\n  if (typeof source === 'string') return !!source.trim()\n  if (typeof source === 'number') return Number.isFinite(source) && source > 0\n  return !!source && (!!source.uri?.trim() || (typeof source.assetId === 'number' && source.assetId > 0))\n}\n\nconst VideoSession = React.forwardRef<VideoHandle, VideoProps & { retry: () => void }>(\n  (\n    {\n      source,\n      active = true,\n      muted = false,\n      loop = false,\n      aspectRatio = 16 / 9,\n      className,\n      style,\n      fullscreenOptions = { enable: true },\n      errorMessage = 'The video could not be loaded.',\n      retryLabel = 'Retry video',\n      onStatusChange,\n      onPlayingChange,\n      retry,\n      accessibilityLabel = 'Video',\n      ...props\n    },\n    ref,\n  ) => {\n    const supplied = hasSource(source)\n    const player = useVideoPlayer(supplied ? source : null)\n    const view = React.useRef<VideoView>(null)\n    const alive = React.useRef(true)\n    const [status, setStatus] = React.useState(player.status)\n    const [foreground, setForeground] = React.useState(AppState.currentState === 'active')\n    const visible = Platform.OS !== 'web' || foreground\n    const available = React.useRef(active && visible)\n    available.current = active && visible\n    const callbacks = React.useRef({ onStatusChange, onPlayingChange })\n    callbacks.current = { onStatusChange, onPlayingChange }\n\n    React.useLayoutEffect(() => {\n      alive.current = true\n      return () => {\n        alive.current = false\n      }\n    }, [])\n    React.useEffect(() => {\n      player.loop = loop\n      player.muted = muted\n      player.staysActiveInBackground = false\n      player.showNowPlayingNotification = false\n    }, [player, loop, muted])\n    React.useEffect(() => {\n      if (!active) player.pause()\n    }, [player, active])\n    React.useEffect(() => {\n      // Native Expo owns app/fullscreen activity transitions. Android fullscreen\n      // pauses the React host while its separate player activity stays visible.\n      if (Platform.OS !== 'web') return\n      const subscription = AppState.addEventListener('change', (state) => {\n        const next = state === 'active'\n        available.current = active && next\n        setForeground(next)\n        if (!next) player.pause()\n      })\n      return () => subscription.remove()\n    }, [player, active])\n    React.useEffect(() => {\n      const statusSubscription = player.addListener('statusChange', (event) => {\n        if (!alive.current) return\n        setStatus(event.status)\n        callbacks.current.onStatusChange?.(event.status, event.error)\n      })\n      const playingSubscription = player.addListener('playingChange', ({ isPlaying }) => {\n        if (!alive.current) return\n        if (isPlaying && !available.current) {\n          player.pause()\n          return\n        }\n        callbacks.current.onPlayingChange?.(isPlaying)\n      })\n      setStatus(player.status)\n      callbacks.current.onStatusChange?.(player.status)\n      callbacks.current.onPlayingChange?.(player.playing)\n      return () => {\n        statusSubscription.remove()\n        playingSubscription.remove()\n      }\n    }, [player])\n    React.useImperativeHandle(\n      ref,\n      () => ({\n        play: () => {\n          if (alive.current && available.current && supplied && player.status !== 'error') player.play()\n        },\n        pause: () => {\n          if (alive.current) player.pause()\n        },\n        replay: () => {\n          if (!alive.current || !available.current || !supplied || player.status === 'error') return\n          player.currentTime = 0\n          player.play()\n        },\n        enterFullscreen: async () => {\n          if (alive.current && available.current && fullscreenOptions.enable) await view.current?.enterFullscreen()\n        },\n      }),\n      [player, supplied, fullscreenOptions.enable],\n    )\n\n    const failed = !supplied || status === 'error'\n    return (\n      <View {...props} className={cn('w-full gap-[12px]', className)} style={style}>\n        {failed ? (\n          <View className=\"min-h-[144px] items-center justify-center gap-[12px] rounded-lg border border-border bg-muted p-[16px]\">\n            <Text>{supplied ? errorMessage : 'No video supplied.'}</Text>\n            {supplied ? (\n              <Button variant=\"outline\" onPress={retry}>\n                {retryLabel}\n              </Button>\n            ) : null}\n          </View>\n        ) : (\n          <View\n            className=\"overflow-hidden rounded-lg bg-black\"\n            style={{ aspectRatio: Number.isFinite(aspectRatio) && aspectRatio > 0 ? aspectRatio : 16 / 9 }}\n          >\n            {/* SDK54's web imperative entry still reads the legacy fullscreen flag. */}\n            <VideoView\n              ref={view}\n              player={player}\n              accessibilityLabel={accessibilityLabel}\n              style={StyleSheet.absoluteFill}\n              pointerEvents={active && visible ? 'auto' : 'none'}\n              nativeControls={active && visible}\n              contentFit=\"contain\"\n              fullscreenOptions={fullscreenOptions}\n              {...(Platform.OS === 'web' && { allowsFullscreen: fullscreenOptions.enable })}\n              allowsPictureInPicture={false}\n              startsPictureInPictureAutomatically={false}\n              playsInline\n            />\n            {status === 'loading' ? (\n              <View pointerEvents=\"none\" className=\"absolute inset-0 items-center justify-center\">\n                <Spinner accessibilityLabel=\"Loading video\" color=\"white\" />\n              </View>\n            ) : null}\n          </View>\n        )}\n      </View>\n    )\n  },\n)\nVideoSession.displayName = 'VideoSession'\n\nexport const Video = React.forwardRef<VideoHandle, VideoProps>((props, ref) => {\n  const [attempt, setAttempt] = React.useState(0)\n  return (\n    <VideoSession\n      {...props}\n      ref={ref}\n      key={JSON.stringify(props.source) + ':' + attempt}\n      retry={() => setAttempt((value) => value + 1)}\n    />\n  )\n})\nVideo.displayName = 'Video'\n",
      "type": "registry:ui",
      "target": "~/components/ui/video/Video.tsx"
    },
    {
      "path": "packages/registry-native/components/video/index.ts",
      "content": "export { Video, type VideoHandle, type VideoProps } from './Video'\n",
      "type": "registry:ui",
      "target": "~/components/ui/video/index.ts"
    }
  ],
  "dependencies": [
    "expo-video"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/spinner.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Foreground-only Expo video with system controls, request lifecycle, error recovery and fullscreen. Bare RN requires Expo Modules.",
  "categories": [
    "media"
  ]
}