Sonic Player
API/Hooks

useBufferedProgress

The useBufferedProgress hook provides updates on the buffer progress and playback status of the expo-sonic-ios-player. It listens to the "onProgress" and "onStatusChange" events emitted by the native module.

🧠 Usage

import { useBufferedProgress } from "expo-sonic-ios-player";

export default function BufferStatus() {
  const { bufferProgress, status } = useBufferedProgress();

  return (
    <div>
      <p>Status: {status}</p>
      <p>Buffered: {(bufferProgress * 100).toFixed(2)}%</p>
    </div>
  );
}

🔁 Events Handled

  • onProgress: Reports the current buffer progress.
  • onStatusChange: Reports the playback status (loading, ready, error, seeked, unknown).

📦 Returns

KeyTypeDescription
bufferProgressnumberA float between 0 and 1 representing the buffered portion of the track.
status"loading" | "ready" | "error" | "seeked" | "unknown"Current playback status reported by the player.

💡 Example Output

Status: ready
Buffered: 82.50%