Skip to main content

useLive()

useLive(): boolean

Returns whether the current media is a live stream.

This hook provides a reactive way to observe and respond to changes in the player’s live state — i.e., whether the current playback represents a live stream or a video-on-demand (VOD) asset.

  • VOD: Returns false. Playback has a fixed duration, from 0 to duration.
  • LIVE: Returns true. Playback is tied to a live stream or broadcast that may have a moving playback window (e.g., DVR or time-shifted playback).

⚠️ Must be used within a PlayerProvider or AVPlayerViewControllerProvider component.

Returns

boolean

boolean true if the current media is live, otherwise false.

Example

import React from 'react';
import { View, Text } from 'react-native';
import { useLive } from '@castlabs/react-native-prestoplay';

export default function StreamTypeIndicator() {
const isLive = useLive();

return (
<View>
<Text>{isLive ? 'Live Stream' : 'Video on Demand'}</Text>
</View>
);
}