Creating a song list for ExoPlayer with CreateListSource, I want to get the track title in the TrackChanged event.
I tried the following code from the forum:
In some cases I can see the title of the track in the metadata but in other cases it does not show.
Is there an issue with this code or is there a better way to do it?
I tried the following code from the forum:
B4X:
Dim jo As JavaObject = ExoPlaySong
Dim TrackGroups As JavaObject = jo.GetFieldJO("player").RunMethod("getCurrentTrackGroups", Null)
For i = 0 To TrackGroups.GetField("length") - 1
Dim TrackGroup As JavaObject = TrackGroups.RunMethod("get", Array(i))
For j = 0 To TrackGroup.GetField("length") - 1
Dim Format As JavaObject = TrackGroup.RunMethodJO("getFormat", Array(j))
Dim Metadata As JavaObject = Format.GetField("metadata")
If Metadata.IsInitialized Then'will not show you anything
Dim jo As JavaObject= Metadata.RunMethod("get", Array(0))
For k = 0 To Metadata.RunMethod("length", Null) - 1
Dim Entry As JavaObject = Metadata.RunMethod("get", Array(k))
Log("Entry: " & Entry)
Next
End If
Next
Next
In some cases I can see the title of the track in the metadata but in other cases it does not show.
Is there an issue with this code or is there a better way to do it?