Integrate Youtube API Into Your Android App
The YouTube Android Player API enables you to incorporate video playback functionality into your Android applications. The API defines methods for loading and playing YouTube videos (and playlists) and for customizing and controlling the video playback experience.
Using the API, you can load or cue videos into a player view embedded in your application's UI. You can then control playback programmatically. For example, you can play, pause, or seek to a specific point in the currently loaded video.
You can also register event listeners to get callbacks for certain events, such as the player loading a video or the player state changing. Finally, the API has helper functionality to support orientation changes as well as transitions to fullscreen playback.
First Download The Youtube Android Player Library.zip From The Link Given Below And Extract This Zip File And Copy The Android Player Library.jar File And Paste In The "Libs" Directory of your android studio projects
Link To Download the Android Player Library For Windows (64 Bit) : https://developers.google.com/youtube/android/player/downloads/YouTubeAndroidPlayerApi-1.2.2.zip
After Adding library Right Click on the library jar file and select the option "Add as a Library"
After Adding library Visit The URL Given Below And Follow Steps To Get Your Own Youtube API Key
Link For Google Api Console :
https://console.cloud.google.com/apis/
Open This Link And Login With Your Google Account when you succesfully logged in with your google account click on the "Select a Project" after selecting this option click on the "+" icon to create a new project
Now Enter the name of your project and click on the create button
Now Click on the hamburger icon located at top left after click on this icon select the option "API and Service" then select "credentials"
Now Click on "create credentials" and select the opton "API Key"
Now Click On The ""Restrict Key" option
Now Choose the Android App Option in the Application Restriction after selecting this option copy the package name your android app and paste in the field of package name and for the sha1 key click on the gradle option located in top right corner and in the root folder click on android app the click on the signing report this all thing is shown in screenshot below
After Doing this all Click On The Save Button And Copy The Api Key In Any Text Editor For coming use
Now Lets Do Some Coding Part
Firstly Add The Internet Permission In The Manifest File
Now Add The Android Player View In The Layout File
Now create a YoutubeService.java file for get the API key
After Getting API Key come to MainActivity.java In This we intilize the Youtube Player for load video in it and give functionality to play button when the play button is pressed the video is start playing in the youtube player view which is set up in the main_activity.xml file
Finally Run Your Android App
Tutorial By Tushar Verma
https://www.linkedin.com/in/tushar-verma-047329154/
Using the API, you can load or cue videos into a player view embedded in your application's UI. You can then control playback programmatically. For example, you can play, pause, or seek to a specific point in the currently loaded video.
You can also register event listeners to get callbacks for certain events, such as the player loading a video or the player state changing. Finally, the API has helper functionality to support orientation changes as well as transitions to fullscreen playback.
First Download The Youtube Android Player Library.zip From The Link Given Below And Extract This Zip File And Copy The Android Player Library.jar File And Paste In The "Libs" Directory of your android studio projects
Link To Download the Android Player Library For Windows (64 Bit) : https://developers.google.com/youtube/android/player/downloads/YouTubeAndroidPlayerApi-1.2.2.zip
After Adding library Right Click on the library jar file and select the option "Add as a Library"
After Adding library Visit The URL Given Below And Follow Steps To Get Your Own Youtube API Key
Link For Google Api Console :
https://console.cloud.google.com/apis/
Open This Link And Login With Your Google Account when you succesfully logged in with your google account click on the "Select a Project" after selecting this option click on the "+" icon to create a new project
Now Enter the name of your project and click on the create button
Now Click on the hamburger icon located at top left after click on this icon select the option "API and Service" then select "credentials"
Now Click on "create credentials" and select the opton "API Key"
Now Click On The ""Restrict Key" option
Now Choose the Android App Option in the Application Restriction after selecting this option copy the package name your android app and paste in the field of package name and for the sha1 key click on the gradle option located in top right corner and in the root folder click on android app the click on the signing report this all thing is shown in screenshot below
After Doing this all Click On The Save Button And Copy The Api Key In Any Text Editor For coming use
Now Lets Do Some Coding Part
Firstly Add The Internet Permission In The Manifest File
Now Add The Android Player View In The Layout File
Now create a YoutubeService.java file for get the API key
After Getting API Key come to MainActivity.java In This we intilize the Youtube Player for load video in it and give functionality to play button when the play button is pressed the video is start playing in the youtube player view which is set up in the main_activity.xml file
Finally Run Your Android App
Tutorial By Tushar Verma
https://www.linkedin.com/in/tushar-verma-047329154/
Important Note : Your Android Device Must Have Youtube App
Komentar
Posting Komentar