For AI agents: the complete documentation index is available at /1.x/llms.txt, the full documentation bundle is available at /1.x/llms-full.txt, and this page is available as Markdown at /1.x/guide/usage/player-controls.md.
  • English
  • 1.x
  • Player Controls

    Version 1.x exposes player controls through a ref.

    import { useRef } from 'react';
    import { Button, View } from 'react-native';
    import { YoutubePlayer, type PlayerControls } from 'react-native-youtube-bridge';
    
    function App() {
      const playerRef = useRef<PlayerControls>(null);
    
      return (
        <View>
          <YoutubePlayer ref={playerRef} source="AbZH7XWDW_k" />
          <Button title="Play" onPress={() => playerRef.current?.play()} />
          <Button title="Pause" onPress={() => playerRef.current?.pause()} />
          <Button title="Seek" onPress={() => playerRef.current?.seekTo(30, true)} />
        </View>
      );
    }

    Common methods

    • play, pause, stop, seekTo
    • setVolume, getVolume, mute, unMute, isMuted
    • getCurrentTime, getDuration, getVideoUrl, getVideoEmbedCode
    • getPlaybackRate, setPlaybackRate, getAvailablePlaybackRates
    • getPlayerState, getVideoLoadedFraction
    • loadVideoById, cueVideoById, setSize