A simple YouTube Player for Android using the YouTube IFrame Player API inside a WebView.
Google has deprecated the Android YouTube Player API (RIP 😢).
This project shows how to play YouTube videos in Android using the IFrame API instead.
It’s lightweight, works on all Android versions (API 23+), and avoids dependency on Google’s deprecated library.
- ✅ Play YouTube videos inside a
WebView - ✅ Simple iFrame embed with customizable URL
- ✅ Regex check for valid YouTube links
- ✅ Works in both portrait/landscape (forced landscape in this demo)
- ✅ Clean & modern Kotlin code (no spaghetti 🍝)
-
Clone the repository:
git clone https://github.com/your-username/YoutubePlayer.git
-
Open in Android Studio.
-
Add Internet permission in your
AndroidManifest.xml:<uses-permission android:name="android.permission.INTERNET" />
Modify the YouTube URL in MainActivity:
private val youTubeUrl = "https://www.youtube.com/embed/JxNXkA2hhzs"Run the app → and boom 💥 video plays inside the WebView.
Add a screenshot of your app here (WebView with video).
- Some videos might not work if the uploader disabled embedding. In that case, you’ll see:
"Video unavailable – Watch on YouTube"
- To fix this → choose a video that allows embedding.
MIT License. Use freely.
If you make something cool with this, send me a star ⭐ on GitHub!