{"id":4498,"date":"2020-08-23T12:08:42","date_gmt":"2020-08-23T02:08:42","guid":{"rendered":"https:\/\/learntodroid.com\/?p=4498"},"modified":"2020-08-23T15:36:48","modified_gmt":"2020-08-23T05:36:48","slug":"how-to-embed-youtube-videos-in-an-android-app-with-android-youtube-player","status":"publish","type":"post","link":"http:\/\/10.0.0.14:32769\/how-to-embed-youtube-videos-in-an-android-app-with-android-youtube-player\/","title":{"rendered":"How to Embed YouTube Videos in an Android App with android-youtube-player"},"content":{"rendered":"\n

Adding video content to your Android app can create a great interactive experience for your users. YouTube offers a massive library of videos and a reliable video streaming platform that you can leverage to embed video into your Android app.<\/p>\n\n\n\n

YouTube offers an official API<\/a> to allow developers to play YouTube videos in their app, however, it has not been updated in a long time and it requires the user to have the YouTube app installed on their device.<\/p>\n\n\n\n

A great alternative free to use, open-source API that allows you to embed YouTube videos to be played within an Android app is android-youtube-player<\/a> created by Pierfrancesco Soffritti<\/a>.<\/p>\n\n\n\n

android-youtube-player uses a WebView with an IFrame to display and expose the controls to the YouTube player. In addition to being able to play videos from YouTube, android-youtube-player also you to customize the user interface of the video player as well as offering the ability to cast YouTube videos from the player to a Chromecast device.<\/p>\n\n\n\n

In this post I will show you how to set up and the android-youtube-player library in your Android project and play YouTube videos embedded into your app.<\/p>\n\n\n\n

The code samples showed in this tutorial are available on GitHub in the following repository.<\/p>\n\n\n\n

https:\/\/github.com\/learntodroid\/AndroidEmbedYouTubeVideoTutorial<\/a><\/p>\n\n\n\n

A video tutorial for this post is available in the embedded YouTube video below.<\/p>\n\n\n\n

\n
https:\/\/www.youtube.com\/watch?v=yyduqrCpKGg<\/a>