| Start |
|---|
Activity extending YouTubeBaseActivity |
Launching StandAlonePlayerActivity |
| Consuming YouTube Data API on Android This example will guide you how to get playlist data using the YouTube Data API on Android. SHA-1 fingerprint First you need to get an SHA-1 fingerprint for your machine. There are various methods for retrieving it. You can choose any method provided in this Q&A (opens new window). Google API console and YouTube key for Android Now that you have an SHA-1 fingerprint, open the Google API console and create a project. Go to this page (opens new window) and create a project using that SHA-1 key and enable the YouTube Data API. Now you will get a key. This key will be used to send requests from Android and fetch data. Gradle part You will have to add the following lines to your Gradle file for the YouTube Data API: In order to use YouTube's native client to send requests, we have to add the following lines in Gradle: The following configuration also needs to be added in Gradle in order to avoid conflicts: Below it is shown how the gradle.build would finally look like. build.gradle Now comes the Java part. Since we will be using Now I want to show how to get playlists via the YouTube API by providing the playlist IDs. For this task I will use The above asynchronous task will return an instance of Finally, in our |
| YoutubePlayerFragment in portrait Activty The following code implements a simple YoutubePlayerFragment. The activity's layout is locked in portrait mode and when orientation changes or the user clicks full screen at the YoutubePlayer it turns to lansscape with the YoutubePlayer filling the screen. The YoutubePlayerFragment does not need to extend an activity provided by the Youtube library. It needs to implement YouTubePlayer.OnInitializedListener in order to get the YoutubePlayer initialized. So our Activity's class is the following A YoutubePlayerFragment can be added to the activity's layout xaml as followed Lastly you need to add the following attributes in your Manifest file inside the activity's tag |
| YouTube Player API Obtaining the Android API Key : First you'll need to get the SHA-1 fingerprint on your machine using java keytool. Execute the below command in cmd/terminal to get the SHA-1 fingerprint. MainActivity.java Now create Config.java xml file Remarks |
Read Article
https://develop.horje.com/learn/1434/reference