{"id":19672670,"url":"https://github.com/halilozel1903/exoplayerdrm","last_synced_at":"2025-06-13T11:07:03.301Z","repository":{"id":49045148,"uuid":"296884322","full_name":"halilozel1903/ExoPlayerDrm","owner":"halilozel1903","description":"How can play DASH type DRM content in ExoPlayer? 📺 📱","archived":false,"fork":false,"pushed_at":"2024-04-10T18:10:56.000Z","size":2248,"stargazers_count":45,"open_issues_count":2,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-13T11:02:54.798Z","etag":null,"topics":["android-example","dash-plugin","dash-video","drm","drm-free","drm-player","exoplayer","exoplayer-beginner","exoplayer-dash","exoplayer-demo","exoplayer-drm","exoplayer-example","exoplayer-kotlin","exoplayer-learn","exoplayer-video","exoplayer2","kotlin-android","mpd-config","video","widevine"],"latest_commit_sha":null,"homepage":"https://medium.com/@halilozel1903","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/halilozel1903.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":"2020-09-19T14:17:14.000Z","updated_at":"2025-04-14T18:16:48.000Z","dependencies_parsed_at":"2024-11-25T16:05:08.825Z","dependency_job_id":null,"html_url":"https://github.com/halilozel1903/ExoPlayerDrm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/halilozel1903/ExoPlayerDrm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FExoPlayerDrm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FExoPlayerDrm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FExoPlayerDrm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FExoPlayerDrm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halilozel1903","download_url":"https://codeload.github.com/halilozel1903/ExoPlayerDrm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halilozel1903%2FExoPlayerDrm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259634346,"owners_count":22887693,"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","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-example","dash-plugin","dash-video","drm","drm-free","drm-player","exoplayer","exoplayer-beginner","exoplayer-dash","exoplayer-demo","exoplayer-drm","exoplayer-example","exoplayer-kotlin","exoplayer-learn","exoplayer-video","exoplayer2","kotlin-android","mpd-config","video","widevine"],"created_at":"2024-11-11T17:12:59.537Z","updated_at":"2025-06-13T11:07:03.280Z","avatar_url":"https://github.com/halilozel1903.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/halilozel1903"],"categories":[],"sub_categories":[],"readme":"## What is DRM? 🤔\n\n![Screenshot](https://miro.medium.com/max/1400/1*LtFxnStWjom2xYQvZsHFow.png)\n\nDigital rights management (DRM) is a way to protect copyrights for digital media. This approach includes the use of technologies that limit the copying and use of copyrighted works and proprietary software.\n\nIn a way, digital rights management allows publishers or authors to control what paying users can do with their works. For companies, implementing digital rights management systems or processes can help to prevent users from accessing or using certain assets, allowing the organization to avoid legal issues that arise from unauthorized use. Today, DRM is playing a growing role in data security.\n\nWith the rise of peer-to-peer file exchange services such as torrent sites, online piracy has been the bane of copyrighted material. DRM technologies do not catch those who engage in piracy. Instead, they make it impossible to steal or share the content in the first place.\n\n\nFor more please read this article : https://streaminglearningcenter.com/articles/what-is-drm.html \u003cbr\u003e \u003cbr\u003e\n\n## Digital rights management - ExoPlayer 📺\n\nExoPlayer uses Android’s ```MediaDrm``` API to support DRM protected playbacks. \n\nThe minimum Android versions required for different supported DRM schemes, along with the streaming formats for which they’re supported, are:\n\nDRM scheme\t | Android version number\t | Android API level | Supported formats\n------------ | ------------- | ------------ | -------------\nWidevine “cenc”\t | 4.4\t| 19 | DASH, HLS (FMP4 only)\nWidevine “cbcs” | 7.1 | 25 | DASH, HLS (FMP4 only)\nClearKey | 5.0 | 21 | DASH\nPlayReady SL2000 | AndroidTV | AndroidTV\t| DASH, SmoothStreaming, HLS (FMP4 only) \n\nIn order to play DRM protected content with ExoPlayer, the UUID of the DRM system and the license server URI should be specified when building a media item. \nThe player will then use these properties to build a default implementation of ```DrmSessionManager```, called ```DefaultDrmSessionManager```, \nthat’s suitable for most use cases. For some use cases additional DRM properties may be necessary, as outlined in the sections below.\n\nFor more please read document : https://exoplayer.dev/drm.html \u003cbr\u003e \u003cbr\u003e\n\n## How to use DRM in ExoPlayer ⁉️\n\nIn order to play a Drm video in Exoplayer, we need to have a DASH(.mdp) type video url. We will decode the encrypted video and play it. \n\nFirst of all, we can start our example by following the steps below.\n\n### Step - 1️⃣\n\nWe are creating an Android project in the Kotlin language.\n\n### Step - 2️⃣\n\nWe add the internet permission to the Android Manifest file.\n\n```kotlin\n\u003cuses-permission android:name=\"android.permission.INTERNET\"/\u003e\n```\n\n### Step - 3️⃣\n\nAdd the link of the ExoPlayer library to the .build gradle file.\n\n```kotlin \nimplementation 'com.google.android.exoplayer:exoplayer:2.17.1'\n```\n\n\n### Step - 4️⃣\n\nIf not enabled already, you need to turn on Java 8 support in all build.gradle files depending on ExoPlayer, by adding the following to the android section:\n\n```kotlin\ncompileOptions {\n        targetCompatibility JavaVersion.VERSION_1_8\n}\n```\n\n### Step - 5️⃣\n\nAdd playerView to the ```activity_main.xml``` file.\n\n\n```kotlin \n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003candroidx.constraintlayout.widget.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:argType=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\".MainActivity\"\u003e\n\n    \u003ccom.google.android.exoplayer2.ui.StyledPlayerView\n        android:id=\"@+id/playerView\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        argType:resize_mode=\"fixed_width\"\n        argType:show_buffering=\"when_playing\"\n        argType:show_fastforward_button=\"true\"\n        argType:show_next_button=\"false\"\n        argType:show_previous_button=\"false\"\n        argType:show_rewind_button=\"true\"\n        argType:show_subtitle_button=\"true\"\n        argType:use_artwork=\"true\"\n        argType:use_controller=\"true\"\u003e\n\n    \u003c/com.google.android.exoplayer2.ui.StyledPlayerView\u003e\n\n\u003c/androidx.constraintlayout.widget.ConstraintLayout\u003e\n```\n\n\n### Step - 6️⃣\n\nPlayer, binding variables have been defined.\n\n```kotlin\nprivate lateinit var playerView: ExoPlayer\nprivate lateinit var binding: ActivityMainBinding\n```\n\n### Step - 7️⃣\n\nA function has been created for the Factory operation.\n\n   ```kotlin\n     val defaultHttpDataSourceFactory = DefaultHttpDataSource.Factory()\n                .setUserAgent(userAgent)\n                .setTransferListener(\n                    DefaultBandwidthMeter.Builder(context)\n                        .setResetOnNetworkTypeChange(false)\n                        .build()\n                )\n\n            val dashChunkSourceFactory: DashChunkSource.Factory = DefaultDashChunkSource.Factory(\n                defaultHttpDataSourceFactory\n            )\n ```\n \n ### Step - 8️⃣\n \n We have created a method in which the necessary operations are performed to play a drm type video.\n \n   ```kotlin\n     val dashMediaSource =\n                DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory)\n                    .createMediaSource(\n                        MediaItem.Builder()\n                            .setUri(Uri.parse(url))\n                             // DRM Configuration\n                            .setDrmConfiguration(\n                                MediaItem.DrmConfiguration.Builder(drmSchemeUuid)\n                                    .setLicenseUri(drmLicenseUrl).build()\n                            )\n                            .setMimeType(MimeTypes.APPLICATION_MPD)\n                            .setTag(null)\n                            .build()\n                    )\n ```\n \n  ### Step - 9️⃣\n  \n  Added url, drm license to play. It is made ready to be played.\n  \n  **Drm License Url** : https://proxy.uat.widevine.com/proxy?provider=widevine_test\n  \n  **Drm Url** : https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/mpds/11331.mpd\n  \n ```kotlin \n  // Prepare the player.\n          playerView = ExoPlayer.Builder(this)\n              .setSeekForwardIncrementMs(10000)\n              .setSeekBackIncrementMs(10000)\n              .build()\n          playerView.playWhenReady = true\n          binding.playerView.player = playerView\n          playerView.setMediaSource(dashMediaSource, true)\n          playerView.prepare()\n  ```\n\n### Step - 🔟\n\nCall the ```initializePlayer()``` function inside `onCreate.`\n\n  ```kotlin\n    override fun onCreate(savedInstanceState: Bundle?) {\n            super.onCreate(savedInstanceState)\n            binding = ActivityMainBinding.inflate(layoutInflater)\n            val view = binding.root\n            setContentView(view)\n            initializePlayer()\n        }\n    }\n```\n\n### Result 📌\n\nYes ✅ The url in DRM type played smoothly. All dash type contents are played on the player with the Drm setting.\n\n\u003cimg src=\"https://github.com/halilozel1903/ExoPlayerDrm/blob/master/drm_dash_pic1.png\" width=\"250\" /\u003e \u003cimg src=\"https://github.com/halilozel1903/ExoPlayerDrm/blob/master/drm_dash_pic2.png\" width=\"250\" /\u003e \u003cbr\u003e\n\n\n**But** ```setDrmConfiguration``` If you make a comment line, you will not be able to view the content.\n\n```kotlin\n .setDrmConfiguration(MediaItem.DrmConfiguration.Builder(drmSchemeUuid)\n                      .setLicenseUri(drmLicenseUrl).build())\n ``` \n\n\u003cimg src=\"https://github.com/halilozel1903/ExoPlayerDrm/blob/master/drm_dash_not_pic1.png\" width=\"250\" /\u003e \u003cimg src=\"https://github.com/halilozel1903/ExoPlayerDrm/blob/master/drm_dash_not_pic2.png\" width=\"250\" /\u003e \u003cbr\u003e\n\n## Donation 💸\n\nIf this project help 💁 you to develop, you can give me a cup of coffee. ☕\n\n[![\"Buy Me A Coffee\"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/halilozel1903)\n\n## Resources 📚\n- https://exoplayer.dev/drm.html\n- https://streaminglearningcenter.com/articles/what-is-drm.html\n- https://digitalguardian.com/blog/what-digital-rights-management\n- https://bitmovin.com/demos/stream-test?format=dash\u0026manifest=https%3A%2F%2Fbitmovin-a.akamaihd.net%2Fcontent%2Fart-of-motion_drm%2Fmpds%2F11331.mpd\n\n\n## License 📋\n```\nMIT License\n\nCopyright (c) 2023 Halil OZEL\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fexoplayerdrm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalilozel1903%2Fexoplayerdrm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalilozel1903%2Fexoplayerdrm/lists"}