Rapid Subscribe Android App

Rapid Subscribe Android App
Rapid Subscriber

Recent Posts

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

create project on google developer console
create project on google developer console

  • Open Api Explorer for your Project

  • Open Api Explorer in Google Developer Console
    Open Api Explorer in Google Developer Console

  • Then Enable Youtube Data Api from Api Explorer

Enable Youtube Data Api from Google Developer Console
Enable Youtube Data Api from Google Developer Console

  • Then click on Create Credentials
Create Credentials on google Developer Console
Create Credentials on google Developer Console


  • Then create a Youtube Data Api Key
Setup Credentials on google Developers console
Setup Credentials on google Developers console


  • Then Copy that Youtube Data Api Key
Copy 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
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.


 
Follow us for more posts like this, 
Subscribe to Harpreet studio on Youtube  
Like Harpreet Studio on Facebook  
Follow me on Instagram 

33 comments:

  1. 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

    ReplyDelete
  2. What 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

    ReplyDelete
  3. this is awesome, i really need this information
    komicast
    noveltoon

    ReplyDelete
  4. 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/

    ReplyDelete
  5. The tip is so helpful. I will bookmark your site to read more from you. Thank for your effort. APK Download

    ReplyDelete
  6. I would like to thank you for the efforts you have made in writing this article Apkdownload

    ReplyDelete
  7. I 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/

    ReplyDelete
  8. Beaver says I also have such interest, you can read my profile here: indian visa

    ReplyDelete
  9. I really like and appreciate your article. Much thanks again. Cool.
    upload reels from pc

    ReplyDelete
  10. I really like and appreciate your post. Much thanks again. Really Cool.
    post to instagram from pc

    ReplyDelete
  11. 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

    ReplyDelete
  12. The 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

    ReplyDelete
  13. So, 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

    ReplyDelete
  14. There 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

    ReplyDelete
  15. 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 communicating on YouTube consistently?buy subscribers twitch

    ReplyDelete
  16. you 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/

    ReplyDelete
  17. All 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

    ReplyDelete
  18. Surprisingly 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

    ReplyDelete
  19. buying 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.

    ReplyDelete
  20. The article posted was very informative and useful. You people are doing a great job. Keep going. youtube downloader online

    ReplyDelete
  21. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing. miamisuperhero reviews

    ReplyDelete
  22. There'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

    ReplyDelete
  23. This 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

    ReplyDelete
  24. Why not something different like MetaCafe or Viddler or other video sharing sites? Why YouTube specifically? How about we view that at this point.
    https://seriestv.org/

    ReplyDelete
  25. Say you got a nice blog post. Really thank you! Really Great.
    yt mp3 converter

    ReplyDelete
  26. 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?
    YTTrend

    ReplyDelete
  27. 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.

    ReplyDelete
  28. https://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.

    ReplyDelete
  29. i love to collect different models of cellphones that is why i have lots of cellphones at home;; https://onlinemusicpromotion.net/buy-youtube-views/

    ReplyDelete
  30. Perhaps 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/

    ReplyDelete
  31. Going 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. زيادة مشتركين يوتيوب

    ReplyDelete
  32. nice post! Please visit my blog to refer to the methods of learning English for children.

    ReplyDelete