![]() ![]() To create a new ‘PlayerActivity’ and the activity_player.xml, add the snippets below to the YouTubePlayerView view.This is the Android Software Development Kit License Agreementġ.1 The Android Software Development Kit (referred to in the License Agreement as the "SDK" and specifically including the Android system files, packaged APIs, and Google APIs add-ons) is licensed to you subject to the terms of the License Agreement. ![]() We will do that in another Activity where the videos are played. Instead, we will display the ‘ids’ of the search results. In other cases, you may include the thumbnails of the videos that were searched, but we will not do that here as that is out of the scope of this tutorial. Go ahead and design the layout for your activity_main.xml to be similar to this:ĭo not forget to create a corresponding RecyclerView row item and its Recycler adapter based on the model class that was created (You can take a look at how my recycler adapter looks like in this Github gist). ![]() Let us define a UI with a search EditText that lets the user search for a given video and a RecyclerView to display the search result. ![]() Open your app-level adle and inside the the defaultConfig, add this line - buildConfigField("String", "YOUTUBE_API_KEY", YOUTUBE_API_KEY) : Open your gradle.properties file and replace the “YOUTUBE_API_KEY_VALUE” with your key: YOUTUBE_API_KEY = "YOUTUBE_API_KEY_VALUE". Once your IDE is launched, create a new Android app project.īefore we begin the implementation, we need to keep our Youtube API key safe so that when you push the code to GitHub, the key is not published. On the side navigation drawer > select Api & Services > click on credentials, you will be directed to another screen.Īt the top bar, click on Create credentials, then click on api key.Ĭopy the API-Key, and keep it somewhere as we will be using it in our app. Make sure your project is selected (at the top navigation bar, you should see the name of your project). In the APIs library, search for youtube data api 3, select it and enable it.You will then be directed to another screen. Click on the side navigation drawer > select Api & Services > Click on Library.Use your google account to get started.Ĭreate a new project and give it a name of your choice. Launch your browser and go to the Google Cloud Platform. The API is simple and has different features that we can leverage to make our apps attractive. The API also requires an API key and registration in the Google cloud console. Instead, one must download the API as a zip file and add it manually to the app. The YouTube API does not have a direct dependency that one can add to the Gradle files. Knows how to use ViewBinding in Android.Android Studio installed on thier computer.To follow along with this tutorial, the reader should have the following: In this tutorial, we will use the YouTube API to create an Android app that allows users to search for YouTube videos and then play them in their Android applications. YouTube offers an Android API that allows developers to add the capability of playing YouTube videos in their app. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |