YouTube Integration with Android Studio

In todays world we are seeing lot of applications having video streaming or demo videos which will give instruction about how your application works. Storing video inside your project will increase apk size, instead of that we can store video on Youtube and stream it. Make a video with this editing software at, and then link your video, which’ll lead the user to Youtube.

Today we will learn how to stream youtube video in your android app.

first step we need to do is obtaining Google API Key, follow this steps to obtain Google API Key.

  1. Get SHA-1 fingerprint from your machine using java Keytool. Execute following command in your cmd/terminal.

On Windows

On Linux/MAC

YouTube Integration

  1. Go to Google Developer Console and create new project.YouTube Integration
  2. Select Enable and manage APIsYouTube Integration
  3. Search for YouTube Data API and enable it.
  4. Move to credentials from left sidebar and create new API key from Add credentials.
  5. From popup asking you for platform, select Android key.
  6. Enter key name<any name> and select Add package name and fingerprint.
  7. Enter your package name and sha-1 key we obtained earlier.YouTube Integration
  8. click on create and you will get your API Key.YouTube Integration

Now we have API Key . Let’s create a new project in Android Studio and start our first Youtube App.

  1. Create new project by navigating to File->New->New Project.
  2. Download latest version of Youtube Android API and find YouTubeAndroidPlayerApi.jar from extracted file.
  3. paste YouTubeAndroidPlayerApi.jar in your project libs folder.YouTube Integration
  4. include jar file dependency in app level build.gradle file
  5. Create variables to store your API key and video id in your activity.
  6. Now add YouTubePlayerView in layout file.

  7. Now extend your MainActivity with YouTubeBaseActivity. Your file will look like below :

  8. Finally add INTERNET permission in your manifest

Here it is, your first program of YouTubeVideoAPI.

Follow me

Ravi Rupareliya

He is author of Android Gig. He loves to explore new technologies and have worked on Android, React Native, Action on Google and Flutter.
Ravi Rupareliya
Follow me
Floting Labels : Text Input Layout
Part of TextView clickable