YouTube API


 

Steps to do before:

In this tutorial, you will learn how to Integrate YouTube Android Player API in Android Application. 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. so lets begin..

Note: This Library requires YouTube Application on the Device and won’t work without it.

 

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, YouTubeFragment.java and add following code :

Step 5 : Open res -> layout -> Create new xml, youtube_activity.xml and add following code :

Step 6 : Open src -> package -> Create new class, YouTubeActivity.java and add following code :

Step 7 : Open res -> layout -> Create new xml, youtube_customlightbox.xml and add following code :

Step 8 : Open src -> package -> Create new class, CustomLightBoxActivity.java and add following code :

Step 9 : Open AndroidManifest.xml and add following code :

Step 10 : Open build.gradle(Module: app) and add following code :

ScreenShot:

youtube youtube_standalone youtube_fragment youtube_activity youtube_custom

Download SourceCode