![]() GetLifecycle(). GitHub - PierfrancescoSoffritti/android-youtube-player: YouTube Player library. To create a new ‘PlayerActivity’ and the activity_player.xml, add the snippets below to the YouTubePlayerView view.I checked the library and it is listed in the documentation that you can change video id as follows: YouTubePlayerView youTubePlayerView = findViewById(R.id.youtube_player_view) androidstudio android firebase javaFirechat with Firebase Android Studio 3 Delete chats with DiffUtil AnimationSource code. YouTube Player library for Android and Chromecast, stable and customizable. First you should try to download the Youtube player library for Android from the link below: Youtube Android Player. 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. This video will demonstrate (1) how to setup a project in Android Studio, (2) how to navigate within Android Studio to build a simple Android application, and (3) how to debug and run an Android. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |