Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cueVideo after a cueVideo #1096

Open
Tino-perf opened this issue Dec 27, 2023 · 2 comments
Open

cueVideo after a cueVideo #1096

Tino-perf opened this issue Dec 27, 2023 · 2 comments
Labels

Comments

@Tino-perf
Copy link

Tino-perf commented Dec 27, 2023

When I load a video with cueVideo and play it, and then when it finishes, and I want to play another video with another cueVideo, the video loads fine, but I have to press the play button on the YouTube video twice for it to start, not just once. It's quite problematic. Here's my code for loading a new video :

public void changerVideoId(String newVideoId) {
if (youTubePlayerView != null) {
youTubePlayerView.getYouTubePlayerWhenReady(new YouTubePlayerCallback() {
@OverRide
public void onYouTubePlayer(@nonnull YouTubePlayer youTubePlayer) {
youTubePlayer.cueVideo(newVideoId, 0); // Load the new video
videoId = newVideoId; // Update the current Video ID
}
});
}
}

Is the only solution to fix this problem to remove the YouTubePlayerView once the first video is finished and then put it back and call cueVideo again? I would prefer not to have to remove the YouTubePlayerView every time. Thank you."

@PierfrancescoSoffritti
Copy link
Owner

Please take a look at the sample app, there are examples doing what you are trying to do.

@Tino-perf
Copy link
Author

Tino-perf commented Dec 29, 2023

Thanks for your answer but I don't find a solution for my problem. I find this code but in my case, I don't want to use loadOrCueVideo because I don't want to launch the videos with a button but just cue a video when I click on the button so this code doesn't work :

private void setPlayNextVideoButtonClickListener(final YouTubePlayer youTubePlayer) {
    Button playNextVideoButton = findViewById(R.id.next_video_button);
    playNextVideoButton.setOnClickListener(view ->
            YouTubePlayerUtils.loadOrCueVideo(
                    youTubePlayer, getLifecycle(),
                    VideoIdsProvider.getNextVideoId(), 0f
            )
    );
  }

Please can you help me to solve the problem ? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants