Skip to content

Instantly share code, notes, and snippets.

@PierfrancescoSoffritti
Created February 11, 2019 19:04
Show Gist options
  • Save PierfrancescoSoffritti/e9ce716c8c9b9ad8e25977eaea3efac4 to your computer and use it in GitHub Desktop.
Save PierfrancescoSoffritti/e9ce716c8c9b9ad8e25977eaea3efac4 to your computer and use it in GitHub Desktop.
android-youtube-player, an open source alternative to the official YouTube Player API: https://medium.com/@soffritti.pierfrancesco/how-to-play-youtube-videos-in-your-android-app-c40427215230
YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view);
getLifecycle().addObserver(youTubePlayerView);
youTubePlayerView.addYouTubePlayerListener(new AbstractYouTubePlayerListener() {
@Override
public void onReady(@NonNull YouTubePlayer youTubePlayer) {
String videoId = "S0Q4gqBUs7c";
youTubePlayer.loadVideo(videoId, 0f);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment