Android Question ExoPlayer-ID3 metadata how to get data

kisoft

Well-Known Member
Licensed User
Hi
This is a continuation of this thread:
https://www.b4x.com/android/forum/threads/exoplayer-id3-metadata.112430/
This is the code that Erel put:
B4X:
Sub Player_TrackChanged
   Dim jo As JavaObject = player1
   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
               Log("Found: " & Metadata)
           End If
       Next
   Next
End Sub
How to dive deeper to get the information you need? It seems that the information you need is in these classes. How to get them.?
https://exoplayer.dev/doc/reference...Metadata.Entry.html#getWrappedMetadataBytes--
 

kisoft

Well-Known Member
Licensed User
Hi
B4X:
Sub Player_TrackChanged
   
''''    All Known Implementing Classes:
''''    ApicFrame, BinaryFrame, ChapterFrame, ChapterTocFrame, CommentFrame, EventMessage, GeobFrame, HlsTrackMetadataEntry,
''''    IcyHeaders, IcyInfo, Id3Frame, InternalFrame, MdtaMetadataEntry, MlltFrame, PictureFrame, PrivateCommand, PrivFrame,
''''    SpliceCommand, SpliceInsertCommand, SpliceNullCommand, SpliceScheduleCommand, TextInformationFrame, TimeSignalCommand,
''''    UrlLinkFrame, VorbisComment
''''  

    Dim jo As JavaObject = player1
    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))
            Log(Format)
            Dim Metadata As JavaObject = Format.GetField("metadata")
            If Metadata.IsInitialized Then
            Log("Metadata: " & Metadata) 'will not show you anything
 
                Dim jo As JavaObject= Metadata.RunMethod("get", Array(0))
                Log ("log2="&jo)
           
                Dim mime As String = jo.GetField("url")
                Log("url: "&mime)
               
                mime=jo.GetField("name")
                Log("name: "&mime)
               
           End If
        Next
    Next

End Sub
B4X:
(Format) Format(null, null, null, audio/mpeg, null, 128000000, null, [-1, -1, -1.0], [2, 44100])
Metadata: (Metadata) com.google.android.exoplayer2.metadata.Metadata@1bf9af3b
log2=(IcyHeaders) IcyHeaders: name="[RMF LADY PANK]", genre="RMF LADY PANK", bitrate=128000000, metadataInterval=1024
url: http://miastomuzyki.pl/
name: [RMF LADY PANK]
 
Last edited:

DonManfred

Expert
Licensed User
Dim jo As JavaObject = player1
Dim TrackGroups As JavaObject = jo.GetFieldJO („player”). RunMethod („getCurrentTrackGroups”, Null)
Dla i = 0 do TrackGroups.GetField („długość”) - 1
Dim TrackGroup As JavaObject = TrackGroups.RunMethod („get”, Array (i))
Please use [CODE]code here...[/CODE] tags when posting code.



 

Erel

Administrator
Staff member
Licensed User
I see that you extracted information from the data. What exactly are you missing?
 

kisoft

Well-Known Member
Licensed User
Hello, happy new year for all of us.
I was able to enter the IcyHeaders class and get the stream name from useful things. I would still like to get the artist name, song name, album cover picture and so on.
This information can be found in other classes. I just don't know how to get into them.

B4X:
''''    All Known Implementing Classes:
''''    ApicFrame, BinaryFrame, ChapterFrame, ChapterTocFrame, CommentFrame, EventMessage, GeobFrame, HlsTrackMetadataEntry,
''''    IcyHeaders, IcyInfo, Id3Frame, InternalFrame, MdtaMetadataEntry, MlltFrame, PictureFrame, PrivateCommand, PrivFrame,
''''    SpliceCommand, SpliceInsertCommand, SpliceNullCommand, SpliceScheduleCommand, TextInformationFrame, TimeSignalCommand,
''''    UrlLinkFrame, VorbisComment
''''
 

Erel

Administrator
Staff member
Licensed User
Add this code and post the output:

B4X:
'after If metadata.IsInitialized
For k = 0 To metadata.RunMethod("length", Null) - 1
Dim Entry As JavaObject = metadata.RunMethod("get", Array(k))
Log("Entry: " & Entry)
Log(GetType(Entry))
Next
 
Last edited:

kisoft

Well-Known Member
Licensed User
I get an error: an unknown user get. I have to join some library?
B4X:
B4A Wersja: 9.50
Java Wersja: 11
Parsowanie kodu.    (0.13s)
Building folders structure.    (0.08s)
Kompilowanie kodu.    Error
Błąd kompilacji programu.
Opis błędu: Nieznany użytkownik: get
Wystąpił błąd w linii: 293
Dim Entry As JavaObject = Metadata.get("get", Array(k))
Word: get
 

kisoft

Well-Known Member
Licensed User
Entry: (IcyHeaders) IcyHeaders: name="[RMF LADY PANK]", genre="RMF LADY PANK", bitrate=128000000, metadataInterval=1024
com.google.android.exoplayer2.metadata.icy.IcyHeaders
resources in this class:
B4X:
IcyHeaders(int bitrate, String genre, String name, String url, boolean isPublic, int metadataInterval)
I can now download them with this code
B4X:
Dim jo As JavaObject= Metadata.RunMethod("get", Array(0))
                Log ("log2="&jo)
          
                Dim mime As String = jo.GetField("url")
                Log("url: "&mime)
              
                mime=jo.GetField("name")
                Log("name: "&mime)
 
Last edited:

kisoft

Well-Known Member
Licensed User
I tested for many streams and unfortunately the effect is the same every time.
 
Last edited:

Syd Wright

Active Member
Licensed User
I get similar results as KiSoft. Here is the code I used, including two radiostreams that do provide ID3 MP3 tag information and with Erels suggestions:
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    Private Player1 As SimpleExoPlayer
End Sub

Sub Globals
    Private SimpleExoPlayerView1 As SimpleExoPlayerView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If FirstTime = True Then
      Player1.Initialize("Player1")
      'Player1.Prepare(Player1.CreateUriSource("http://18973.live.streamtheworld.com/RADIO538.mp3"))
      Player1.Prepare(Player1.CreateUriSource("http://stream.bollenstreekomroep.nl/live-mp3-192-stereo"))
    End If

    SimpleExoPlayerView1.Player = Player1
    Player1.Play
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Player1_Ready
    Log("Ready")
End Sub

Sub Player1_Error (Message As String)
    Log("Error: " & Message)
End Sub

Sub Player1_Complete
    Log("complete")
End Sub

Sub Player1_TrackChanged
    Log("Player Track Changed!")
    Dim jo As JavaObject = Player1
    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))
        Log(Format)
        Dim Metadata As JavaObject = Format.GetField("metadata")
        If Metadata.IsInitialized Then
              
          For k = 0 To Metadata.RunMethod("length", Null) - 1
            Dim Entry As JavaObject = Metadata.RunMethod("get", Array(k))
            Log("Entry: " & Entry)
            Log(GetType(Entry))
          Next             
              
          Log("Metadata: " & Metadata) 'will not show you anything

          Dim jo As JavaObject= Metadata.RunMethod("get", Array(0))
          Log ("log2="&jo)
        
          Dim mime As String = jo.GetField("url")
          Log("url: "&mime)
            
          mime=jo.GetField("name")
          Log("name: "&mime)
        End If
      Next
    Next
End Sub
 

Almora

Active Member
Licensed User
I am also interested in reading the artist name and song title for radiostreams with Exoplayer. So far I use AAC Player which works very well but unfortunately seems no longer supported and does crash after using it for a while. See: https://www.b4x.com/android/forum/t...io-aac-decoder-for-android.59567/#post-498602
Can you post the streams and the entire B4A code so I can take a look?
I am also interested in reading the artist name and song title for radiostreams with Exoplayer.
exo player can do it with plugin ..

 

Syd Wright

Active Member
Licensed User
exo player can do it with plugin ..
Yes, thank you, I also already found that today, but have no idea how to implement it in B4A. Maybe Erel can help...
There might also be ways to get the ID3 data without adding a plugin to Exoplayer, but I have also not found anything (yet).
 
Last edited:

Syd Wright

Active Member
Licensed User
In Windows, VLC player also has the ability to read mp3 id3 metatags and does show the Artist name and Song title! It can be found under the tab "Extra" and then "Media-information". I tried Moster67's VLC library for B4A, but it does not (yet) include this feature.
 

kisoft

Well-Known Member
Licensed User
I hope we can solve this problem, or I'll lose my contract. (customer order)
 
Last edited:
Top