{"id":20881487,"url":"https://github.com/js-bhavyansh/exo_player","last_synced_at":"2026-05-16T18:02:52.399Z","repository":{"id":250442665,"uuid":"834476630","full_name":"js-bhavyansh/Exo_Player","owner":"js-bhavyansh","description":"Jetpack Compose example app showcasing ExoPlayer with online, raw, and YouTube video playback.","archived":false,"fork":false,"pushed_at":"2024-08-30T08:22:18.000Z","size":21807,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-07T06:37:09.380Z","etag":null,"topics":["android","exoplayer","jetpack-compose","kotlin","media-playback","navigation-compose","serialization","video-player","youtube-integration"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/js-bhavyansh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-27T11:39:48.000Z","updated_at":"2024-08-30T08:22:21.000Z","dependencies_parsed_at":"2024-10-22T08:56:48.286Z","dependency_job_id":null,"html_url":"https://github.com/js-bhavyansh/Exo_Player","commit_stats":null,"previous_names":["bhavyansh03-tech/exo_player","js-bhavyansh/exo_player"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/js-bhavyansh/Exo_Player","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bhavyansh%2FExo_Player","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bhavyansh%2FExo_Player/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bhavyansh%2FExo_Player/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bhavyansh%2FExo_Player/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/js-bhavyansh","download_url":"https://codeload.github.com/js-bhavyansh/Exo_Player/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/js-bhavyansh%2FExo_Player/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274005336,"owners_count":25205934,"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-09-07T02:00:09.463Z","response_time":67,"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","exoplayer","jetpack-compose","kotlin","media-playback","navigation-compose","serialization","video-player","youtube-integration"],"created_at":"2024-11-18T07:25:02.816Z","updated_at":"2026-05-16T18:02:52.310Z","avatar_url":"https://github.com/js-bhavyansh.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExoPlayer Example\n\nThis repository demonstrates how to use ExoPlayer in a Jetpack Compose application. It includes three different player implementations:\n- **Online Player**: Streams video from an online URL.\n- **Raw Player**: Plays a video stored in the raw resources of the app.\n- **YouTube Player**: Embeds a YouTube video using a `WebView`.\n\n## Prerequisites\n\n- Android Studio with Jetpack Compose setup\n- ExoPlayer dependency in your `build.gradle` file\n- Internet permissions if using the Online Player\n\n1. Clone the repository:\n\n   ```sh\n     git clone https://github.com/Bhavyansh03-tech/Exo_Player.git\n   ```\n   \n2. Open the project in Android Studio.\n3. Build the project and run it on an emulator or a physical device.\n\n## Screenshots\n\u003cimg src=\"https://github.com/user-attachments/assets/7b16e0de-536a-42d9-862b-342ba2fcd667\" alt=\"First Screenshot\" style=\"width: 200px; height: auto; margin-right: 10px;\"\u003e\n\u003cimg src=\"https://github.com/user-attachments/assets/60666de7-e93a-4f88-934d-d4bb0d89e22e\" alt=\"Second Screenshot\" style=\"width: 200px; height: auto; margin-right: 10px;\"\u003e\n\u003cimg src=\"https://github.com/user-attachments/assets/cd82e250-c62f-4335-965f-cf3e48ab2b0e\" alt=\"Third Screenshot\" style=\"width: 200px; height: auto;\"\u003e\n\n## Setup\n\n1. **Add Dependencies**\n\n   Make sure you have the following dependencies in your `build.gradle` file:\n\n   ```toml\n   [libraries]\n   # YOUTUBE PLAYER :-\u003e\n   androidx-webkit = { module = \"androidx.webkit:webkit\", version.ref = \"webkit\" }\n   \n   # MEDIA EXO PLAYER :-\u003e\n    androidx-media3-exoplayer = { module = \"androidx.media3:media3-exoplayer\", version.ref = \"media3Exoplayer\" }\n    androidx-media3-exoplayer-hls = { module = \"androidx.media3:media3-exoplayer-hls\", version.ref = \"media3Exoplayer\" }\n    androidx-media3-ui = { module = \"androidx.media3:media3-ui\", version.ref = \"media3Exoplayer\" }\n   ```\n\n2. **Add Internet Permission (for Online Player)**\n\n   In your `AndroidManifest.xml`, add the following permission:\n\n   ```xml\n   \u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e\n   ```\n\n## Composables\n\n###  OnlinePlayer\n\nStreams video from an online URL.\n\n```kotlin\n// Media Item :-\u003e\nval mediaItem = MediaItem.fromUri(\"https://cdn.pixabay.com/video/2024/04/18/208442_large.mp4\") // Apply Changes.\n\n// Media source :-\u003e\nval mediaSource: MediaSource = ProgressiveMediaSource.Factory(DefaultHttpDataSource.Factory()) // Add this.\n    .createMediaSource(mediaItem)\n\nval exoPlayer = remember {\n    ExoPlayer.Builder(context).build().apply {\n        setMediaSource(mediaSource)  // Apply Changes.\n        prepare()\n        playWhenReady = true\n    }\n}\n```\n\n### RawPlayer\n\nPlays a video stored in the raw resources of the app.\n\n```kotlin\n@Composable\nfun RawPlayer() {\n\n    // Lifecycle :-\u003e\n    var lifecycle by remember {\n        mutableStateOf(Lifecycle.Event.ON_CREATE)\n    }\n\n    // Get context :-\u003e\n    val context = LocalContext.current\n\n    // Media Item :-\u003e\n    val mediaItem = MediaItem.fromUri(\"android.resource://${context.packageName}/${R.raw.sample}\")\n\n    // Media source :-\u003e\n    val exoPlayer = remember {\n        ExoPlayer.Builder(context).build().apply {\n            setMediaItem(mediaItem)\n            prepare()\n            playWhenReady = true\n        }\n    }\n\n    // Lifecycle for composable :-\u003e\n    val lifecycleOwner = LocalLifecycleOwner.current\n    DisposableEffect(key1 = lifecycleOwner) {\n        val observer = LifecycleEventObserver { _, event -\u003e\n            lifecycle = event\n        }\n        lifecycleOwner.lifecycle.addObserver(observer)\n\n        onDispose {\n            exoPlayer.release()\n            lifecycleOwner.lifecycle.removeObserver(observer)\n        }\n    }\n\n    // Android View :-\u003e\n    AndroidView(\n        modifier = Modifier\n            .fillMaxWidth()\n            .aspectRatio(16f / 9f),\n        factory = {\n            PlayerView(context).also { playerView -\u003e\n                playerView.player = exoPlayer\n            }\n        },\n        update = {\n            when (lifecycle){\n                Lifecycle.Event.ON_RESUME -\u003e {\n                    it.onPause()\n                    it.player?.pause()\n                }\n                Lifecycle.Event.ON_PAUSE -\u003e {\n                    it.onResume()\n                }\n                else -\u003e Unit\n            }\n        }\n    )\n}\n```\n\n### YoutubePlayer\n\nEmbeds a YouTube video using a `WebView`.\n\n```kotlin\n@Composable\nfun YoutubePlayer(videoId: String) {\n    AndroidView(\n        modifier = Modifier.fillMaxSize().padding(top = 25.dp),\n        factory = { context -\u003e\n            WebView(context).apply {\n                webViewClient = WebViewClient()\n                settings.javaScriptEnabled = true\n                loadUrl(\"https://youtu.be/$videoId\")\n            }\n        }\n    )\n}\n```\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.\n\n1. Fork the repository.\n2. Create your feature branch (`git checkout -b feature/your-feature`).\n3. Commit your changes (`git commit -am 'Add some feature'`).\n4. Push to the branch (`git push origin feature/your-feature`).\n5. Create a new Pull Request.\n\n## Contact\n\nFor questions or feedback, please contact [@Bhavyansh03-tech](https://github.com/Bhavyansh03-tech) on GitHub or connect with me on [LinkedIn](https://www.linkedin.com/in/bhavyansh03/).\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjs-bhavyansh%2Fexo_player","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjs-bhavyansh%2Fexo_player","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjs-bhavyansh%2Fexo_player/lists"}