usePlayer()
usePlayer():
Player
Returns the current Player instance, allowing direct control over media playback.
This hook provides access to the active Player object, which exposes
methods for controlling playback — such as play(), pause(), and replay().
⚠️ Must be used within a PlayerProvider or AVPlayerViewControllerProvider component.
Typically used together with other player-related hooks for complete playback management:
- usePlayerState – provides the current playback state (e.g., playing, paused, ended).
Returns
Player The active Player instance.
Example
const player = usePlayer();
const playerState = usePlayerState();
const onPress = useCallback(() => {
if (playerState === PlayerState.Ended) {
player?.replay();
}
}, [player, playerState]);