Created
February 11, 2019 16:59
-
-
Save PierfrancescoSoffritti/862002cd14aab7c1a0c29fbd18355a78 to your computer and use it in GitHub Desktop.
How to send YouTube videos from your Android app to a Chromecast device: https://medium.com/@soffritti.pierfrancesco/how-to-send-youtube-videos-from-your-android-app-to-a-chromecast-device-541d59ea1260
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class SimpleChromecastConnectionListener implements ChromecastConnectionListener { | |
@Override | |
public void onChromecastConnecting() { | |
Log.d(getClass().getSimpleName(), "onChromecastConnecting"); | |
} | |
@Override | |
public void onChromecastConnected(ChromecastYouTubePlayerContext chromecastYouTubePlayerContext) { | |
Log.d(getClass().getSimpleName(), "onChromecastConnected"); | |
initializeCastPlayer(chromecastYouTubePlayerContext); | |
} | |
@Override | |
public void onChromecastDisconnected() { | |
Log.d(getClass().getSimpleName(), "onChromecastDisconnected"); | |
} | |
private void initializeCastPlayer(ChromecastYouTubePlayerContext chromecastYouTubePlayerContext) { | |
chromecastYouTubePlayerContext.initialize(new AbstractYouTubePlayerListener() { | |
@Override | |
public void onReady(YouTubePlayer youTubePlayer) { | |
youtubePlayer.loadVideo("6JYIGclVQdw", 0f); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment