Exploring Youtube Data Api V3
Exploring Youtube Data Api V3 Tutorial
In this blog, we use YouTube Data Api V3 for Android. We will enable Youtube api by creating project on google Cloud Console and then download Youtube Api jar file and add it to our project. Then we load a video in our Youtube player View.
For Youtube Data Api V3 Listeners Tutorial click here
For Youtube Data Api V3 detailed methods click here
For creating seek to millis(jump to specific location of video) click here
To implement youtube Data Api in android you have to create a project in Goole Cloud Console and enable Youtube Data Api
- open Console.developers.google.com and create a project there.
create project on google developer console |
- Open Api Explorer for your Project
- Then Enable Youtube Data Api from Api Explorer
Enable Youtube Data Api from Google Developer Console |
- Then click on Create Credentials
Create Credentials on google Developer Console |
- Then create a Youtube Data Api Key
Setup Credentials on google Developers console |
- Then Copy that Youtube Data Api Key
Copy Youtube Data Api Key |
- Then Create a project in Android Studio and open Strings.xml and paste api key there.
<string name="youtube_api_key">AIzaSy***************************13UdI</string>
- Then Open this link and download Youtube Data Api V3
- Then Extract zip file and copy youtube data api.jar file and paste in your project as shown in picture below.
youtube data api in project libs folder |
- Then add implementation library in app level build.gradle file.
implementation files('libs/YouTubeAndroidPlayerApi.jar')
Then add Youtube player View in XML file.
XML activity
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">
<com.google.android.youtube.player.YouTubePlayerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/youtube_player"/>
</LinearLayout>
Then implements Youtube Base Activity and implements oninitializationlistener in JAVA Activity
activity.java
package studio.harpreet.sampleyoutubedataapi;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;
import java.util.ArrayList;
import static android.content.ContentValues.TAG;
public class MainActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {
YouTubePlayerView youTubePlayerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
youTubePlayerView = findViewById(R.id.youtube_player);
youTubePlayerView.initialize(getString(R.string.youtube_api_key),this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
if(!b)
{
//youTubePlayer.cueVideo("-_pacR6syDo"); //https://www.youtube.com/watch?v=-_pacR6syDo
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
if (youTubeInitializationResult.isUserRecoverableError()) {
youTubeInitializationResult.getErrorDialog(this, 1).show();
} else {
String error = String.format("Error initializing YouTube Player ", youTubeInitializationResult.toString());
Toast.makeText(this, error, Toast.LENGTH_LONG).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 1)
{
getYoutubePlayerProvider().initialize(getString(R.string.youtube_api_key),this);
}
}
private YouTubePlayer.Provider getYoutubePlayerProvider() {
return youTubePlayerView;
}
}
Now Run your project and it successfully runs your Youtube player and loads your video.
Subscribe to Harpreet studio on Youtube
Like Harpreet Studio on Facebook
Follow me on Instagram
it's truly pleasant and meanful. it's truly cool blog. Connecting is exceptionally valuable thing.you have truly helped heaps of individuals who visit blog and give them usefull btclod.com
ReplyDeleteWhat an informative post you share here! I learn more knowledges about Youtube Data Api V3 thanks to this blog! Keep up your work! apk.care
ReplyDeletethis is awesome, i really need this information
ReplyDeletekomicast
noveltoon
YouTube has an incentive for upgrading address conversations of different public talking subjects and issues. 74% of the understudies overviewed showed that they like to watch a video during a show. Public talking teachers battle to discover opportune models and outlines. I as of late used a discourse found on YouTube that was conveyed to Columbia University understudies by Lee Bollinger, the leader of the college. https://www.buyyoutubeviewsindia.in/youtube-marketing/
ReplyDeleteThe tip is so helpful. I will bookmark your site to read more from you. Thank for your effort. APK Download
ReplyDeleteI would like to thank you for the efforts you have made in writing this article Apkdownload
ReplyDeleteI visit your blog regularly and recommend it to all of those who wanted to enhance their knowledge with ease. The style of writing is excellent and also the content is top-notch. Thanks for that shrewdness you provide the readers! https://www.buyyoutubeviewsindia.in/youtube-marketing/
ReplyDeleteBeaver says I also have such interest, you can read my profile here: indian visa
ReplyDeleteI really like and appreciate your article. Much thanks again. Cool.
ReplyDeleteupload reels from pc
I really like and appreciate your post. Much thanks again. Really Cool.
ReplyDeletepost to instagram from pc
You have an early mover advantage. 2012 is a top for the standard in the US and the UK. I haven't took a gander at insights for places like China or India,Buy high retention youtube views
ReplyDeleteThe number one video site in the world is now YouTube. Globally it is widely recognised and more and more content gets added to it each day. Because of this massive growth YouTube advertising is of great benefit to internet marketers. buy youtube views
ReplyDeleteSo, you want to make money on YouTube but have no idea how to go about it. If used wisely YouTube can be a great tool for your Internet Marketing business. There are several ways you can harness the power to YouTube. Some of the examples are: your site promotion, developing an e mail list, marketing as an affiliate etc. Like any marketing tool YouTube will have a learning curve. buy youtube views
ReplyDeleteThere are some interesting points on time here but I do not know if they all center to heart. There is some validity but Let me take hold opinion until I take a look at it further. Great post , thanks and we want more! Included in FeedBurner in addition onlinemusicpromotion.net
ReplyDeleteHow might you situate yourself so you can be in the most ideal position when this standard, individuals in the US and the UK, hit YouTube and get on YouTube and begin communicating on YouTube consistently?buy subscribers twitch
ReplyDeleteyou this bouncing point to get into the early greater part. When you hit the early larger part, that is the point at which you hit the tipping point. That is when things go big an ideal opportunity for you. https://www.buyyoutubesubscribers.in/
ReplyDeleteAll of us love planning to theatres to see the newest blockbusters. But, we must also keep a on our Personal finances all at once, assure not to overspend. 123movie
ReplyDeleteSurprisingly fast, you can be on your technique to positioning or assessing the YouTube recordings you appreciate or in any event, distributing your own recordings! Buy high retention youtube views
ReplyDeletebuying yt views By having a YouTube account, you can increase your likability to Google's search engine algorithm. This can mean increased traffic to your website and increased revenue.
ReplyDeleteThe article posted was very informative and useful. You people are doing a great job. Keep going. youtube downloader online
ReplyDeleteReally nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing. miamisuperhero reviews
ReplyDeleteThere's little that transports you out from the daily grind than grabbing a bucket of popcorn, a big soft drink and sitting back to like a blockbuster movie. watch series online
ReplyDeleteThis is very interesting content! I have thoroughly enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great. yt mp3 converter
ReplyDeleteWhy not something different like MetaCafe or Viddler or other video sharing sites? Why YouTube specifically? How about we view that at this point.
ReplyDeletehttps://seriestv.org/
very useful information, thank you for sharing
ReplyDeleteVisit my homepage at here
Say you got a nice blog post. Really thank you! Really Great.
ReplyDeleteyt mp3 converter
How might you situate yourself so you can be in the most ideal position when this standard, individuals in the US and the UK, hit YouTube and get on YouTube and begin associating on YouTube consistently?
ReplyDeleteYTTrend
httpstwitchviral.com Many games have emerged during the last decade with the words "Lord of the Rings" in their name, from traditional board games to Monopoly: The Lord of the Rings Trilogy Edition and Risk: The Lord of the Rings. The Lord of the Rings: The Card Game is a Living Card Game (LGG). Let's see if it stands out from the crowd.
ReplyDeletehttps://twitchviral.com/ A Gaming Computer, also known as gaming PC, is a personal computer that is capable of playing computationally and graphically demanding video games. They are very similar to conventional computers with the exception that these machines are fitted with performance-oriented video card and other specifications.
ReplyDeletei love to collect different models of cellphones that is why i have lots of cellphones at home;; https://onlinemusicpromotion.net/buy-youtube-views/
ReplyDeletePerhaps the simplest way you can assist with guaranteeing the outcome of a discourse is to plan fascinating and strong visual guides. https://www.spotifyfame.com/
ReplyDeleteGoing to graduate school was a positive decision for me. I enjoyed the coursework, the presentations, the fellow students, and the professors. And since my company reimbursed 100% of the tuition, the only cost that I had to pay on my own was for books and supplies. Otherwise, I received a free master’s degree. All that I had to invest was my time. زيادة مشتركين يوتيوب
ReplyDeletenice post! Please visit my blog to refer to the methods of learning English for children.
ReplyDelete