How Play YouTube Videos Android Application

How Play YouTube Videos Android Application – Here i will give the detailed explanation about YouTube API and how to used for our android application. Let’s see how to play the YouTube videos in your android application using YouTube official API. When you have get videos from YouTube just give permission from YouTube. I mean first you have to get API and then get the YouTube videos from server. Suppose you did’t get API and access YouTube videos your application suspended or affect from any other reason.

How Play YouTube Videos Android Application

So move on the official way to integrate YouTube videos and get full access. When you have follow the official steps you did’t affect any way to loss your applications. Most of students are using WebView concept for Play the YouTube Videos in Android Application but that’s totally wrong way when you have upload the app from play store.

In this application very used for who plan to launch android application in Google Play Store. If you are not plan to publish the application in play store then you have ready my another article of Video Gallery Application Android. In this article will help you add YouTube videos Automatically from your server.

Get YouTube API Key

YouTube API key is a important part of our project so first you have get the YouTube API key officially then move on the other steps.

1. First Open the Google Developer API Consloe after go to on the click just Create New Project then the API Services are displayed.

2. Now click View All tab, then click to choose the YouTube Data API v3 Service.

3. After choose the YouTube Data API v3, the below screen will be opened. Now you have to click Enable button.

4. When you have click the Enable button, next the Credentials page will be opened.

5. Now you have click to create credentials button, after click the button the choose Android on the tab then the API key will be created.

That’s all, the YouTube API Integration part is finished. Now you have start to develop the structure of code to view the YouTube Videos in you Android Application.

Create New Project

AS usual create new project and give some name for the application then choose Empty Activity. After creating project just follow my steps, how to play the YouTube Videos in our Android Application using the YouTube Video URL (Id). In this project i will create four directories to interact the JAVA classes for Activity Layouts.

Before write you need to download the Jar file YouTube Android Player API. After downloading the Jar file you have add from Project dependency.

Create Class File

Project create with under of five directory, every classes depends on the Layout files to fetch the YouTube Videos via API. First we create MainActivity.java class.

MainActivity.java

Now create the class of YoutubePlayerActivity file to get YouTube Video ID’s.

YoutubePlayerActivity.java

Other four directory class codes are very long so in last i have include full source code of this project you can download that. In below i will explain the Activity Layout files only.

Activity Layouts

Under the path of res => values => strings.xml. Just open the file and add the following below code. Here you have to add your YouTube videos ID only then the YouTube API’s are fetch and display the full videos in your application

Other layout files are added from source code so you can download the code below.

Play YouTube Videos Android
Click to download

Output ScreenShot

This is J.Vetrivel pandian completed MCA & lives in Udangudi,India. Blogging is my Passion, I love to write article about Programming. Apart from blogging, I’ll run Grocery Store that’s my Profession.