MrSiro
MrSiro

Reputation: 291

Android youtube player cueVideos not auto play

I'm using Youtube SDK in my Android project. I want to play video list. I have used below methods :

player.cueVideos(List<String> videoIds, int startIndex, int timeMillis);
player.play();

but Youtube player does not auto play.I must press Play button to play the video. How do I can set auto play ?

Thanks for all.

Upvotes: 0

Views: 2132

Answers (1)

Dmitriy Mitiai
Dmitriy Mitiai

Reputation: 1200

I know I'm late with answer, but it could be helpful for some.

In your implementation when you call play immediately, after cueVideos(...), the player have not time to load any stream and your paly() call will be ignored, because:

cueVideos(List videoIds, int startIndex, int timeMillis) Cues a list of videos, but does not download any of the video streams or start playing until play() or seekToMillis(int) is called.

If you want to auto play, just use loadVideos(...) instead of cueVideos(...)

mYouTubePlayer.loadVideos(videosList);

or if you want to use the last one, just wait for few secs and then call play() like below:

mYouTubePlayer.cueVideos(videosList);

new Handler().postDelayed(new Runnable() {
     @Override
     public void run() {
         mYouTubePlayer.play();
     }
}, 5000);

Upvotes: 5

Related Questions