Skip to content

epegasus/YoutubePlayer

Repository files navigation

🎬 YoutubePlayer

A simple YouTube Player for Android using the YouTube IFrame Player API inside a WebView.


📌 About

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.


⚡ Features

  • ✅ 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 🍝)

🛠️ Setup

  1. Clone the repository:

    git clone https://github.com/your-username/YoutubePlayer.git
  2. Open in Android Studio.

  3. Add Internet permission in your AndroidManifest.xml:

    <uses-permission android:name="android.permission.INTERNET" />

🚀 Usage

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.


📷 Screenshot

Add a screenshot of your app here (WebView with video).


📌 Notes

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

📄 License

MIT License. Use freely.
If you make something cool with this, send me a star ⭐ on GitHub!

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages