Android Question How to create a RTMP Datasource for Exoplayer?

DonManfred

Expert
Licensed User
Longtime User

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Download the attached zip and copy the two files to the additional libraries folder. It is a compilation of: https://github.com/ant-media/LibRtmp-Client-for-Android
2. Add these two lines:
B4X:
#AdditionalJar: rtmp-client-3.0.0.aar
#AdditionalJar: rtmp.jar

3. You can play RTMP streams with:
B4X:
player1.CreateUriSource("rtmp://live-fs.wmncdn.net/mbctv1/live1.stream")
 

Attachments

  • rtmp-client.zip
    275.7 KB · Views: 677
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
1. Download the attached zip and copy the two files to the additional libraries folder. It is a compilation of: https://github.com/ant-media/LibRtmp-Client-for-Android
2. Add these two lines:
B4X:
#AdditionalJar: rtmp-client-3.0.0.aar
#AdditionalJar: rtmp.jar

3. You can play RTMP streams with:
B4X:
player1.CreateUriSource("rtmp://live-fs.wmncdn.net/mbctv1/live1.stream")
After the update on ExoPlayer for 1.2.0, this should be work right? Or need to do some procedure?


upload_2019-7-8_12-9-18.png
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        player1.Initialize("player")
        Dim sources As List
        sources.Initialize
        ' sources.Add(player1.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
       
        sources.Add(player1.CreateUriSource("rtmp://live-fs.wmncdn.net/mbctv1/live1.stream"))
        player1.Prepare(player1.CreateListSource(sources))
       
    End If
    Activity.LoadLayout("1")
    SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub


and the LOG
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/butterflytv/rtmp_client/RtmpClient;
at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:59)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:257)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:934)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "net.butterflytv.rtmp_client.RtmpClient" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.example-CJad3Zim7-KPxRLs6cIgRQ==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-CJad3Zim7-KPxRLs6cIgRQ==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 8 more
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/butterflytv/rtmp_client/RtmpClient;
at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:59)
at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:257)
at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:934)
at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "net.butterflytv.rtmp_client.RtmpClient" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/b4a.example-CJad3Zim7-KPxRLs6cIgRQ==/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example-CJad3Zim7-KPxRLs6cIgRQ==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 8 more
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I Tried using the files in post #7 with the Exoplayer wrapper 1.50 and I am getting this error when I try to start the stream:
B4X:
23:11:49: ExoPlayer Error: net.butterflytv.rtmp_client.RtmpClient$RtmpIOException

Sub Player_Error_Sub (Message As String, Exoo As SimpleExoPlayerView)
    Log(DateTime.Time(DateTime.Now) & ": ExoPlayer Error: " & Message)
End Sub

Then I tried just using the "additional aar files" from the ExoPlayer lib page (and removed the #additionalJar statements from post #7):


And I am getting the same error as Alberto:

B4X:
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/butterflytv/rtmp_client/RtmpClient;
    at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:48)
    at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:201)
    at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
    at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1015)
    at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.ClassNotFoundException: net.butterflytv.rtmp_client.RtmpClient
    ... 8 more
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/butterflytv/rtmp_client/RtmpClient;
    at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:48)
    at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:201)
    at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
    at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1015)
    at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.ClassNotFoundException: net.butterflytv.rtmp_client.RtmpClient
    ... 8 more
 
Last edited:
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
I Tried using the files in post #7 with the Exoplayer wrapper 1.50 and I am getting this error when I try to start the stream:
B4X:
23:11:49: ExoPlayer Error: net.butterflytv.rtmp_client.RtmpClient$RtmpIOException

Sub Player_Error_Sub (Message As String, Exoo As SimpleExoPlayerView)
    Log(DateTime.Time(DateTime.Now) & ": ExoPlayer Error: " & Message)
End Sub

Then I tried just using the "additional aar files" from the ExoPlayer lib page (and removed the #additionalJar statements from post #7):


And I am getting the same error as Alberto:

B4X:
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/butterflytv/rtmp_client/RtmpClient;
    at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:48)
    at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:201)
    at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
    at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1015)
    at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.ClassNotFoundException: net.butterflytv.rtmp_client.RtmpClient
    ... 8 more
java.lang.NoClassDefFoundError: Failed resolution of: Lnet/butterflytv/rtmp_client/RtmpClient;
    at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:48)
    at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:201)
    at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:84)
    at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1015)
    at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:415)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.ClassNotFoundException: net.butterflytv.rtmp_client.RtmpClient
    ... 8 more

I know this is an old thread, but the error shows that you dont have rtmp client jar for net.butterflytv.rtmp_client.
Current exoplayer library is outdated newer version have many improvements for RTmp rtsp functionality.
To fix the error and get the rtmp works with exoplayer you need the rtmpclient aar which is deprecated for newer exoplayer versions. To get the old rtmp client you can download it from this archive
 
Upvote 0
Top