Android Question ExoPlayer-ID3 metadata how to get data

kisoft

Well-Known Member
Licensed User
Longtime 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
Longtime 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:
Upvote 0

DonManfred

Expert
Licensed User
Longtime 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.

codetag001.png

codetag002.png

codetag003.png
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime 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
''''
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime 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:
Upvote 0

kisoft

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

Almora

Active Member
Licensed User
Longtime 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 ..

 
Upvote 0

kisoft

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

kisoft

Well-Known Member
Licensed User
Longtime User
Fortunately, most of the streams it uses do not contain this data anyway. That's why this code is enough here. For the rest I download via Okhttp and update manually (unfortunately this requires using a timer to refresh and treat each station separately).

P.S. On Android, every failure can be picked up. Connect in USB mode...
 
Last edited:
Upvote 0

PdeG

Member
Licensed User
Longtime User
(first post :eek:)

It's not to difficult, I created a php script that retrieves the meta data. I can share the php code if you need it.
see the result for NPO SterrenNL

B4X:
.
.
.
    url = $"http://ice.pdeg.nl/getIcy.php?url=${Starter.selectedStream}"$
    job.Initialize("", Me)
    job.Download(url)
    job.GetRequest.Timeout = Starter.jobTimeOut
    Wait For (job) JobDone(job As HttpJob)
        
        
    If job.Success Then
        nSong = job.GetString
        job.Release
.
.
.

Regards
 
Upvote 0
Top