YouTube API Android auto start YouTube API Android auto start android android

YouTube API Android auto start


What you are looking for is the Youtube API's loadVideo method. From the docs:

public abstract void loadVideo (String videoId)

Loads and plays the specified video.

You can use it like this:

@Override public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,    boolean wasRestored) {  this.player = player;  player.loadVideo(video.id); // where video.id is a String of a Youtube video ID}

In a similar vein, there is also the cueVideo method, which adds the video to the playlist, but does not automatically start playing the video.


Using loadVideo function.

public abstract void loadVideo (String videoId, int timeMillis)

Loads and plays the specified video. Playback will start at the specified time in the video.

videoId - The ID of the video to be playedtimeMillis - The time in milliseconds

FYR: https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayer#loadVideo(java.lang.String)reader


You need to use player.cueVideo("video_id");

This will load the video, but it will not start auto playing. The video is auto playing because you're using player.loadVideo("video_id");.

Hope it helps.