The YouTubeStandaloneAndroid class provides static methods to launch standalone players on Android. All methods require an apiKey.
playVideo(options)
Launches a standalone player for a single video.
apiKey (string): Required.videoId (string): Required.autoplay (boolean): Default false.lightboxMode (boolean): Play in lightbox instead of fullscreen. Default false.startTime (number): Starting time in seconds. Default 0.
playVideos(options)
Launches a standalone player for a list of videos.
apiKey (string): Required.videoIds (string[]): Required.autoplay (boolean): Default false.lightboxMode (boolean): Default false.startIndex (number): Index of first video. Default 0.startTime (number): Starting time in seconds. Default 0.
playPlaylist(options)
Launches a standalone player for a YouTube playlist.
apiKey (string): Required.playlistId (string): Required.autoplay (boolean): Default false.lightboxMode (boolean): Default false.startIndex (number): Index of first video. Default 0.startTime (number): Starting time in seconds. Default 0.
import { YouTubeStandaloneAndroid } from 'react-native-youtube';
YouTubeStandaloneAndroid.playVideo({
apiKey: 'YOUR_API_KEY',
videoId: 'KVZ-P-ZI6W4',
autoplay: true,
startTime: 120,
})
.then(() => console.log('Standalone Player Exited'))
.catch(errorMessage => console.error(errorMessage));