{"id":24644423,"url":"https://github.com/KhubaibKhan4/MediaPlayer-KMP","last_synced_at":"2025-10-07T04:32:12.483Z","repository":{"id":247033869,"uuid":"824861524","full_name":"KhubaibKhan4/MediaPlayer-KMP","owner":"KhubaibKhan4","description":"MediaPlayer-KMP is a Kotlin Multiplatform (KMP) library that allows you to display and play YouTube videos across Android, iOS, Web, and Desktop platforms using JetBrains Compose Multiplatform. It provides a unified API for video playback that seamlessly integrates into Kotlin's multiplatform ecosystem.","archived":false,"fork":false,"pushed_at":"2025-09-29T07:38:30.000Z","size":8749,"stargazers_count":255,"open_issues_count":17,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-29T08:22:00.598Z","etag":null,"topics":["android-application","compose-multiplatform-library","kmp-library","kotlin-multiplatform","kotlin-multiplatform-library","kotlin-multiplatform-mobile","media-player","media-player-kmp"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KhubaibKhan4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"KhubaibKhan4","patreon":"MuhammadKhubaibImtiaz","open_collective":null,"ko_fi":"muhammadkhubaibimtiaz","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"khubaibkhan","custom":"https://paypal.me/18.bscs"}},"created_at":"2024-07-06T06:38:38.000Z","updated_at":"2025-09-29T07:38:33.000Z","dependencies_parsed_at":"2024-07-15T06:28:32.467Z","dependency_job_id":"55fba4fb-807d-4027-8e03-ff80cce9fb17","html_url":"https://github.com/KhubaibKhan4/MediaPlayer-KMP","commit_stats":null,"previous_names":["khubaibkhan4/mediaplayer-kmp"],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/KhubaibKhan4/MediaPlayer-KMP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhubaibKhan4%2FMediaPlayer-KMP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhubaibKhan4%2FMediaPlayer-KMP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhubaibKhan4%2FMediaPlayer-KMP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhubaibKhan4%2FMediaPlayer-KMP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KhubaibKhan4","download_url":"https://codeload.github.com/KhubaibKhan4/MediaPlayer-KMP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KhubaibKhan4%2FMediaPlayer-KMP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278722630,"owners_count":26034459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-application","compose-multiplatform-library","kmp-library","kotlin-multiplatform","kotlin-multiplatform-library","kotlin-multiplatform-mobile","media-player","media-player-kmp"],"created_at":"2025-01-25T14:01:23.510Z","updated_at":"2025-10-07T04:32:12.473Z","avatar_url":"https://github.com/KhubaibKhan4.png","language":"Kotlin","funding_links":["https://github.com/sponsors/KhubaibKhan4","https://patreon.com/MuhammadKhubaibImtiaz","https://ko-fi.com/muhammadkhubaibimtiaz","https://buymeacoffee.com/khubaibkhan","https://paypal.me/18.bscs","https://ko-fi.com/Y8Y2YABZ7'"],"categories":["Libraries"],"sub_categories":["📱 Device"],"readme":"# MediaPlayer-KMP\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.khubaibkhan4/mediaplayer-kmp.svg?label=Maven%20Central)](https://search.maven.org/artifact/io.github.khubaibkhan4/mediaplayer-kmp)\n![GitHub License](https://img.shields.io/github/license/KhubaibKhan4/MediaPlayer-KMP)\n![GitHub Issues](https://img.shields.io/github/issues/KhubaibKhan4/MediaPlayer-KMP)\n![GitHub Pull Requests](https://img.shields.io/github/issues-pr/KhubaibKhan4/MediaPlayer-KMP)\n![GitHub Last Commit](https://img.shields.io/github/last-commit/KhubaibKhan4/MediaPlayer-KMP)\n![GitHub Stars](https://img.shields.io/github/stars/KhubaibKhan4/MediaPlayer-KMP?style=social)\n![SavePalestine](https://raw.githubusercontent.com/OneDroid/.github/refs/heads/main/images/badge/save-palestine.svg)\n\n![Supported Platforms](https://img.shields.io/badge/platform-Android-green.svg)\n![Supported Platforms](https://img.shields.io/badge/platform-iOS-blue.svg)\n![Supported Platforms](https://img.shields.io/badge/platform-JS-yellow.svg)\n![Supported Platforms](https://img.shields.io/badge/platform-JVM-red.svg)\n![Supported Platforms](https://img.shields.io/badge/platform-WASMJS-blue.svg)\n\n\u003cimg src=\"https://img.shields.io/liberapay/patrons/KhubaibKhanDev.svg?logo=liberapay\"\u003e\n\u003c/br\u003e\n\u003ca href='https://ko-fi.com/Y8Y2YABZ7' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n![Untitledvideo-MadewithClipchamp57-ezgif com-video-to-gif-converter](https://github.com/user-attachments/assets/37a34a60-e5ad-48c5-9e4e-7a974cd40c62)\n\n## Overview\n\nMediaPlayer-KMP is a Kotlin Multiplatform (KMP) library that allows you to display and play YouTube\nvideos across Android, iOS, Web, and Desktop platforms using JetBrains Compose Multiplatform. It\nprovides a unified API for video playback that seamlessly integrates into Kotlin's multiplatform\necosystem.\n\n## Features\n\n- **Platform Agnostic:** Supports Android, iOS, Web, and Desktop platforms through Kotlin\n  Multiplatform.\n- **Compose Multiplatform Integration:** Seamlessly integrates with JetBrains Compose Multiplatform\n  UI framework.\n- **YouTube Video Playback:** Easily load and play YouTube videos with minimal setup.\n- **Audio Player Playback:** Easily load and play Audios with minimal setup.\n- **Event Handling:** Provides callbacks and event listeners for video playback actions and events.\n- **Streaming Support:** Provides Streaming Support For the Video and Audio Links.\n- **AutoPlay:** AutoPlayer Support Implementation.\n- **Auth Token:** Authentication Token Implementation.\n- **ReelsView Support:** Reels View Support Implementation.\n\n## Future Plans\n\n- **Desktop Playback Support**.\n- **Audio player Customisation Support**.\n- **Video and Audio picker for Android, iOS, Web and Desktop.**\n- **Local Content Support.**\n- **Playback Support.**\n\n## Installation\n\nYou can include MediaPlayer-KMP in your project by adding the following dependency:\n\n**Version Catelog**\n\n```\n[versions]\nmediaPlayerKMP = \"2.0.9\"\n\n[libraries]\nalert-kmp = { module = \"io.github.khubaibkhan4:mediaplayer-kmp\", version.ref = \"mediaPlayerKMP\" }\n\n```\n\n```groovy\nimplementation(\"io.github.khubaibkhan4:mediaplayer-kmp:2.0.9\")\n```\n\n## Usage\n\n### YouTube Video Player\n\nFor the YouTube Player, you just need to provide the youtube video link. It will automatically\ndetect it \u0026 will launch the YouTube Player.\n\n```groovy\nimport io.github.khubaibkhan4.mediaplayer.VideoPlayer\n\nfun main() {\n    VideoPlayer(modifier = Modifier.fillMaxWidth().height(340.dp),\n            url = \"https://www.youtube.com/watch?v=AD2nEllUMJw\", // Automatically Detect the URL, Wether to Play YouTube Video or .mp4 e.g\n            showControls: Boolean = true,\n    )\n}\n```\n\n### Video Player\n\nFor the YouTube Player, you just need to provide the youtube video link. It will automatically\ndetect it \u0026 will launch the YouTube Player. It almost supports all the video extensions.\n\n```groovy\nimport io.github.khubaibkhan4.mediaplayer.VideoPlayer\n\nfun main() {\n    VideoPlayer(modifier = Modifier.fillMaxWidth().height(340.dp),\n            url = \"https://freetestdata.com/wp-content/uploads/2022/02/Free_Test_Data_1MB_MP4.mp4\", // Automatically Detect the URL, Wether to Play YouTube Video or .mp4 e.g\n            showControls: Boolean = true,\n    )\n}\n```\n### Play Local File\n\nTo Play Local files, you just need to provide the file path.\n\n```groovy\nimport io.github.khubaibkhan4.mediaplayer.VideoPlayer\n\nfun main() {\n   VideoPlayerScreen(\n                url = filePath,\n                autoPlay = false,\n                onInteraction = {},\n                showControls = true\n   )\n}\n```\n\n## Audio Player Support\n\nAudio Player Support is Implemented. It supports `mp3` `wav` `aac` `ogg` `m4a`. It Supports Play\nBack, Volume Up, Down and Stability as well.\n\n```groovy\nimport io.github.khubaibkhan4.mediaplayer.VideoPlayer\n\nfun main() {\n    MediaPlayer(\n            modifier = Modifier.fillMaxWidth(),\n            url = \"https://commondatastorage.googleapis.com/codeskulptor-demos/DDR_assets/Kangaroo_MusiQue_-_The_Neverwritten_Role_Playing_Game.mp3\",\n            startTime = Color.Black,\n            endTime = Color.Black,\n            volumeIconColor = Color.Black,\n            playIconColor = Color.Blue,\n            sliderTrackColor = Color.LightGray,\n            sliderIndicatorColor = Color.Blue,\n            showControls: Boolean = true,\n    )\n}\n```\n\n### Authentication Token Support\n\nProviding the Auth Tokens are pretty simple. You just need to add the headers. You can add the\nheaders with key and value pairs.\n\n```groovy\nMediaPlayer(\n        modifier = Modifier.fillMaxSize(),\n        url = \"https://example.com/protected-video.mp4\",\n        headers = mapOf(\n                \"Authorization\" to \"Bearer your_token\",\n                \"Custom-Header\" to \"YourValue\"\n        ),\n        startTime = Color.Red,\n        endTime = Color.Blue,\n        autoPlay = true,\n        volumeIconColor = Color.Green,\n        playIconColor = Color.Yellow,\n        sliderTrackColor = Color.Gray,\n        sliderIndicatorColor = Color.Magenta,\n        showControls: Boolean = true,\n)\n\n\n```\n\n## Reels View Support\n\n```groovy\n@Composable\nfun MainScreen() {\n    val videoUrls = listOf(\n            \"https://www.example.com/video1.mp4\",\n            \"https://www.example.com/video2.mp4\",\n            \"https://www.example.com/video3.mp4\"\n    )\n    ReelsView(\n            videoUrls = videoUrls,\n            pagerType = PagerType.Vertical, // Choose PagerType.Vertical or PagerType.Horizontal\n            modifier = Modifier.fillMaxSize(),\n            autoPlay = true, // Enable auto-play for videos\n            showControls: Boolean = true,\n            onInteraction = { page, url -\u003e\n                println(\"User interacted with page $page, video URL: $url\")\n            }\n    )\n}\n\n\n```\n\n## Embed Content from Url:\n```\nval viewer = HtmlContentViewerFactory().createHtmlContentViewer()\nval htmlEmbedFeature = HtmlEmbedFeature(viewer)\n\nhtmlEmbedFeature.embedHtml(\n    url = \"https://github.com/KhubaibKhan4/MediaPlayer-KMP/\",\n    options = EmbedOptions(\n        customCss = \"body { background-color: #f0f0f0; }\",\n        onPageLoaded = { println(\"Page loaded successfully!\") },\n        onError = { error -\u003e println(\"Error loading page: $error\") }\n    )\n)\n\nHtmlContentViewerView(\n    viewer = viewer,\n    modifier = Modifier\n        .fillMaxSize()\n)\n\n```\n\n### JavaScript execution + element querying\n```\nval viewer = HtmlContentViewerFactory().createHtmlContentViewer()\n\nviewer.loadUrl(\"https://example.com\")\nviewer.setPageLoadListener {\n    viewer.evaluateJavaScript(\"document.title\") { title -\u003e\n        println(\"Page title: $title\")\n    }\n}\n\n```\n\n## 🤝 Connect with Me\n\nLet's chat about potential projects, job opportunities, or any other collaboration! Feel free to\nconnect with me through the following channels:\n\n[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue?style=for-the-badge\u0026logo=linkedin)](https://www.linkedin.com/in/khubaibkhandev)\n[![Twitter](https://img.shields.io/badge/Twitter-Follow-blue?style=for-the-badge\u0026logo=twitter)](https://twitter.com/codespacepro)\n[![Email](https://img.shields.io/badge/Email-Drop%20a%20Message-red?style=for-the-badge\u0026logo=gmail)](mailto:18.bscs.803@gmail.com)\n\n## 💰 You can help me by Donating\n\n[![BuyMeACoffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?style=for-the-badge\u0026logo=buy-me-a-coffee\u0026logoColor=black)](https://buymeacoffee.com/khubaibkhan) [![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge\u0026logo=paypal\u0026logoColor=white)](https://paypal.me/18.bscs) [![Patreon](https://img.shields.io/badge/Patreon-F96854?style=for-the-badge\u0026logo=patreon\u0026logoColor=white)](https://patreon.com/MuhammadKhubaibImtiaz) [![Ko-Fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge\u0026logo=ko-fi\u0026logoColor=white)](https://ko-fi.com/muhammadkhubaibimtiaz)\n\n## Screenshots\n\n| ![Screenshot 1](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/1.png) | ![Screenshot 2](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/2.png)                              | ![Screenshot 3](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/3.png) |\n|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|\n ![Screenshot 2](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/6.png) | ![Screenshot_20240710_153958](https://github.com/KhubaibKhan4/MediaPlayer-KMP/assets/98816544/bbda1012-f4a9-46ad-824a-66a710c67c0b) \n\n| ![Screenshot 1](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/4.png)                                | \n|---------------------------------------------------------------------------------------------------------------------------------------|\n| ![Screenshot 2](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/5.png)                                | \n| ![Screenshot 2024-07-10 153852](https://github.com/KhubaibKhan4/MediaPlayer-KMP/assets/98816544/1238c26b-8553-459d-b606-7da89459eb04) |\n| ![Screenshot 2024-07-10 153944](https://github.com/KhubaibKhan4/MediaPlayer-KMP/assets/98816544/2bd8bd9e-298c-4488-8348-8f94b6705a66) |\n\n## Embedded Content Support\n\n| Mobile  | Desktop  |\n|---------|---------|\n| ![Screenshot 1](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/android.png) | ![Screenshot 2](https://github.com/KhubaibKhan4/MediaPlayer-KMP/blob/master/assests/screenshots/desktop.png) |\n                           \n\n## Demo\n\nhttps://github.com/KhubaibKhan4/MediaPlayer-KMP/assets/98816544/657ad29d-5129-4f78-af56-ad354ba0935d\n\n## Desktop Demo\n\nhttps://github.com/KhubaibKhan4/MediaPlayer-KMP/assets/98816544/efd68685-2f41-4445-ad76-c183869ab93a\n\n## Star History\n\n\u003ca href=\"https://star-history.com/#KhubaibKhan4/MediaPlayer-KMP\u0026Timeline\"\u003e\n \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=KhubaibKhan4/MediaPlayer-KMP\u0026type=Timeline\u0026theme=dark\" /\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=KhubaibKhan4/MediaPlayer-KMP\u0026type=Timeline\" /\u003e\n   \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=KhubaibKhan4/MediaPlayer-KMP\u0026type=Timeline\" /\u003e\n \u003c/picture\u003e\n\u003c/a\u003e\n\n**Stargazers**\n\n[![Stargazers repo roster for @KhubaibKhan4/MediaPlayer-KMP](http://reporoster.com/stars/dark/KhubaibKhan4/MediaPlayer-KMP)](https://github.com/KhubaibKhan4/YMediaPlayer-KMP/stargazers)\n\n**Forkers**\n\n[![Forkers repo roster for @KhubaibKhan4/MediaPlayer-KMP](http://reporoster.com/forks/dark/KhubaibKhan4/MediaPlayer-KMP)](https://github.com/KhubaibKhan4/MediaPlayer-KMP/network/members)\n\n## Contribution Guidelines\n\nWe welcome contributions to the MediaPlayer-KMP Library Project! To contribute, please follow these\nguidelines:\n\n- **Reporting Bugs**: If you encounter a bug, please open an issue and provide detailed information\n  about the bug, including steps to reproduce it.\n- **Suggesting Features**: We encourage you to suggest new features or improvements by opening an\n  issue and describing your idea.\n- **Submitting Pull Requests**: If you'd like to contribute code, please fork the repository, create\n  a new branch for your changes, and submit a pull request with a clear description of the changes.\n\n## Support Us:\n\n- We need your support for doing more open source contributions.\n\n## Code of Conduct\n\nWe expect all contributors and users of the MediaPlayer-KMP Library Project to adhere to our code of\nconduct. Please review the [Code of Conduct](CODE_OF_CONDUCT.md) for details on expected behavior\nand reporting procedures.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKhubaibKhan4%2FMediaPlayer-KMP","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKhubaibKhan4%2FMediaPlayer-KMP","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKhubaibKhan4%2FMediaPlayer-KMP/lists"}