### Start Local Development Server Source: https://github.com/lonelycpp/react-native-youtube-iframe/blob/master/website/README.md Starts a local development server for the website. Changes are reflected live without requiring a server restart, facilitating rapid development. ```shell yarn start ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/lonelycpp/react-native-youtube-iframe/blob/master/website/README.md Installs the necessary dependencies for the project using Yarn. This is typically the first step before running other commands. ```shell yarn ``` -------------------------------- ### Playlist Prop Example - react-native-youtube-iframe Source: https://github.com/lonelycpp/react-native-youtube-iframe/blob/master/docs/props.mdx Demonstrates how to use the 'playList' prop to specify a YouTube playlist. It accepts either a playlist ID string or an array of video ID strings. ```javascript playList={'PLbpi6ZahtOH6Blw3RGYpWkSByi_T7Rygb'} or playList={['QRt7LjqJ45k', 'fHsa9DqmId8']} ``` -------------------------------- ### Add Local Dependency to package.json Source: https://github.com/lonelycpp/react-native-youtube-iframe/blob/master/CONTRIBUTING.md This snippet shows how to add the react-native-youtube-iframe library as a local dependency in your test application's package.json file. This allows you to test changes made directly in the cloned repository without publishing them. Ensure the path points to your cloned folder. ```json { "dependencies": { "react-native-youtube-iframe": "path/to/cloned/folder" } } ``` -------------------------------- ### React Native YouTube Iframe Component Example Source: https://context7.com/lonelycpp/react-native-youtube-iframe/llms.txt Demonstrates the usage of the YoutubeIframe component for embedding and controlling YouTube videos within a React Native application. It includes state management for playback, event handlers for player state changes and errors, and imperative API calls for seeking and retrieving current playback time. Dependencies include React, React Native core components, and the react-native-youtube-iframe library. ```jsx import React, { useRef, useState } from 'react'; import { View, Button, StyleSheet } from 'react-native'; import YoutubeIframe, { PLAYER_STATES } from 'react-native-youtube-iframe'; const VideoPlayer = () => { const playerRef = useRef(null); const [playing, setPlaying] = useState(false); const [currentTime, setCurrentTime] = useState(0); const onStateChange = (state) => { console.log('Player state:', state); if (state === PLAYER_STATES.PLAYING) { setPlaying(true); } else if (state === PLAYER_STATES.PAUSED) { setPlaying(false); } }; const onError = (error) => { console.error('Player error:', error); }; const onReady = () => { console.log('Player is ready'); }; const handleGetCurrentTime = async () => { if (playerRef.current) { const time = await playerRef.current.getCurrentTime(); setCurrentTime(time); console.log('Current time:', time); } }; const handleSeek = () => { if (playerRef.current) { playerRef.current.seekTo(30, true); } }; return (