Docs
React SDK

MediaLoader

Render an accessible loading indicator while capture or playback starts.

Import

React
import { MediaLoader, useMediaTrack } from '@relayrtc/react'
import type { RoomRemoteTrack } from '@relayrtc/react'

Requirements

Use playback state from useMediaTrack, capture pending from useLocalMedia, or connection state from useRoom.

The loader component itself does not require a provider.

Props

PropTypeDefaultPurpose
labelstringLoading mediaText announced with role=status.
childrenReactNodelabelCustom visible label.
classNamestringOptionalStyle the container to suit your layout.
Other div propsHTMLAttributes<HTMLDivElement>OptionalStandard DOM props, including style and aria attributes.

Example

React
function Video({ track }: { track: RoomRemoteTrack }) {
  const media = useMediaTrack(track)
 
  return (
    <div style={{ position: 'relative' }}>
      <video ref={media.ref} autoPlay playsInline />
      {media.isLoading && (
        <MediaLoader
          label="Loading camera"
          style={{ display: 'flex', alignItems: 'center', gap: 12 }}
        />
      )}
    </div>
  )
}

Behavior

The component renders an animated SVG and label with role="status" and aria-live="polite". It does not detect loading, subscribe to tracks or change transport speed.