Android Question [SOLVED] - ExoPlayer - Displaying song title and artist name when streaming

rleiman

Well-Known Member
Licensed User
Greetings,

I'm using the ExoPlayer to steam a live radio show. Is the player able to extract the song title and artist name for the currently playing song?

Thanks.
 

rleiman

Well-Known Member
Licensed User
Did you use search?
I'm actually doing the search now but didn't find anything yet. Still searching but will try that coding in the link you sent first.

Is there a way to find out the list of all available data I can get from the player?
 

rleiman

Well-Known Member
Licensed User
Unfortunately that's above my head.

I was able to get the metadata but it's very limited. There is no song title or artist in the data. Here is the coding I used at the _TrackChanged sub routine.

B4X:
Sub player_TrackChanged
    Log ("The 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))
            Dim Metadata As JavaObject = Format.GetField("metadata")
            If Metadata.IsInitialized Then
                Log("Found: " & Metadata)
            End If
        Next
    Next
End Sub
Here's the metadata that's extracted:

B4X:
Found: (Metadata) entries=[IcyHeaders: name="VIFM", genre="Easy Listening", bitrate=320000, metadataInterval=16000]
Another issue I found with the ExoPlayer is that it did not detect that the streaming changed the track when they radio station plays a new song. Is there a way to more metadata that contains the song title and artist? Since the ExoPlayer can't detect the track change, I think I will need to set up a timer and call the sub routine every 5 seconds or so even though it will have a slight delay in reporting the information to the user.
 

PdeG

Member
Licensed User
I created a php script to retrieve the meta data

 

rleiman

Well-Known Member
Licensed User
I created a php script to retrieve the meta data

Thanks for the script. After a lot of searching, I found that the server my customer is using has an API that will return JSON showing all of that good stuff. I will search for examples on calling the API and extracting JSON in the forum so I will mark this post as solved.

The radio station server software is from: Here

The API documentation is: Here
 
Last edited:

Almora

Active Member
Licensed User
Thanks for the script. After a lot of searching, I found that the server my customer is using has an API that will return JSON showing all of that good stuff. I will search for examples on calling the API and extracting JSON in the forum so I will mark this post as solved.

The radio station server software is from: Here

The API documentation is: Here
Can you add a sample project ..It will be very useful.
 

kisoft

Well-Known Member
Licensed User
Here's a project that has coding to extract the song title and artist's name from the current song playing based on the graph provided by This tool.

Link to the project.

View attachment 102005
You can do this for one station or group of the same broadcaster. However, if you want to play several thousand streams, this method doesn't make sense. Each sender uses its own solutions and it requires separate treatment.
 

rleiman

Well-Known Member
Licensed User
You can do this for one station or group of the same broadcaster. However, if you want to play several thousand streams, this method doesn't make sense. Each sender uses its own solutions and it requires separate treatment.
It's for only one station who hired me that's located in Malaysia for the visually impaired community. It will be a free no-advert app that will be on the Play Store.
 
Top