Integrating ExoPlayer in Jetpack Compose Android

Muhammad Danish
Apr 23, 2022
https://9to5google.com/2021/07/28/jetpack-compose-1-0-android-ui-kotlin/

Hi Android Devs in this article i am going to show you how you can integrate latest exoplayer library in your jetpack compose android app. My code does not contains any deprecated code in integration of exoplayer.

First declare exoplayer library in your gradle file:

implementation "com.google.android.exoplayer:exoplayer:2.17.1"

Note: only use latest library of exoplayer else you will face errors in your code.

Now add Internet permission in your android manifest file:

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

If you face below exception:

com.google.android.exoplayer2.upstream.HttpDataSource$CleartextNotPermittedException

then add line in your application tag in manifest file.

android:usesCleartextTraffic="true"

Now go to your activity and write below code:

Now call uiContainer() from setContent{} inside onCreate method of your activity.

Output:

Check this repository for full code:

--

--