Android Question Error in new exoplayer

mehdipass

Active Member
Hi, In the new version of exoplayer, I get the following error:
B4X:
java.lang.RuntimeException: Constructor not found.
This error in b4a reference to this code:
B4X:
Sub CreateMergedSource(Sources() As Object) As Object
   Dim arr As JavaObject
   arr.InitializeArray("com.google.android.exoplayer2.source.MediaSource", Sources)
   Dim m As JavaObject
   Return m.InitializeNewInstance("com.google.android.exoplayer2.source.MergingMediaSource", Array(arr))
End Sub

Sub CreateSingleSampleMediaSource (Uri As String) As Object
   Dim format As JavaObject
   format = format.InitializeStatic("com.google.android.exoplayer2.Format").RunMethod("createTextSampleFormat", Array(Null, "application/x-subrip", 1, "en"))
   Dim source As JavaObject
   Dim u As Uri
   u.Parse(Uri)
   Dim exo As JavaObject = player1
   source.InitializeNewInstance("com.google.android.exoplayer2.source.SingleSampleMediaSource", Array(u, exo.RunMethod("createDefaultDataFactory", Null), _
       format, -9223372036854775807)) ' error in this line (Constructor not found)
   Return source
End Sub
See this
 

mehdipass

Active Member
Which line raises this error?
Hi Erel,
This line
B4X:
 source.InitializeNewInstance("com.google.android.exoplayer2.source.SingleSampleMediaSource", Array(u, exo.RunMethod("createDefaultDataFactory", Null), _
 format, -9223372036854775807)) ' error in this line (Constructor not found)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Try this:
B4X:
Dim format As JavaObject
format = format.InitializeStatic("com.google.android.exoplayer2.Format").RunMethod("createTextSampleFormat", Array(Null, "application/x-subrip", 1, "en"))
Dim u As Uri
Dim factory As JavaObject
factory.InitializeNewInstance("com.google.android.exoplayer2.source.SingleSampleMediaSource$Factory", Array(exo.RunMethod("createDefaultDataFactory", Null)))
Dim source As JavaObject = factory.RunMethod("createMediaSource", Array(u, format, -9223372036854775807)) 'long number = C.TIME_UNSET
 
Upvote 0
Top