Playing UDP, RTP stream using Exoplayer2
Hello, this is a simple and minimal code example to play UDP, RTP stream videos using ExoPlayer 2.
Please find useful resources regarding Network streaming and Exoplayer 2 at the end of the article.
Step 1:
Add INTERNET permission in the manifest file.
<uses-permission android:name=”android.permission.INTERNET” />
Step 2:
Add exoplayer 2 dependencies in your app’s build.gradle file.
implementation ‘com.google.android.exoplayer:exoplayer:2.10.0’
Note: use the latest exoplayer version when using the example.
Step 3:
Create a simple playerview in your layout file.
<com.google.android.exoplayer2.ui.PlayerViewandroid:id=”@+id/player_view”android:layout_width=”match_parent”android:layout_height=”wrap_content” />
Step 4:
Add the following code to initialize defaults and play the UDP stream.
Useful resources:
1. UDP (Wikipedia)- https://en.wikipedia.org/wiki/User_Datagram_Protocol
2. What is UDP — https://searchnetworking.techtarget.com/definition/UDP-User-Datagram-Protocol
3. Exoplayer 2 — https://exoplayer.dev/hello-world.html
4. Exoplayer 2 (Github) — https://github.com/google/ExoPlayer
Please check out the complete project on GitHub
Thanks.