Android Question exoplayer help

apti

Member
I am using exoplayer to play both mp3 and radio streams. Works very nice. however I am using the following code to get the station name. thank erel for that. however I have a use case that needs something else. I have a list of cyrptic urls that play various radio stations. Is there a way to get the station name from each URL without having to play each? Let's say I have a list of things that are currently being played and I want to add a station to the list. I need to get the station name from the URL without stopping the playback of what is already playing. The station name of course will be stored with the URL. So I need to take the new URL and get the name without playing the new URL or stopping the currently playing one.

get station name:
    Dim jo As JavaObject = MPL
    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.RunMethodJO("get", Array(j))
'                Log (jo)
                Dim mime As String = jo.GetField("name")
'                Log(mime)
            End If
        Next
    Next
    Return mime
 

Pendrush

Well-Known Member
Licensed User
Longtime User
You can do it with OkHttp by queryng header of radio station stream:
For example this station stream:
Return this headers:
HTTP/1.0 200 OK
icy-notice1:<BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
icy-notice2:Shoutcast DNAS/posix(linux x64) v2.6.1.777<BR>
Accept-Ranges:none
Access-Control-Allow-Origin:*
Cache-Control:no-cache,no-store,must-revalidate,max-age=0
Connection:close
icy-name:Metal Rock Radio
icy-genre:Metal Hard Rock Classic
icy-br:128
icy-sr:44100
icy-url:http://metalrockradio.com
icy-pub:1
content-type:audio/mpeg
X-Clacks-Overhead:GNU Terry Pratchett
 
Upvote 0

apti

Member
You can do it with OkHttp by queryng header of radio station stream:
For example this station stream:
Return this headers:
I am guessing that the last line "terry pratchett" is the artist and his song name just before it? but the question is how do I get that? I tried something like this and ended up getting alot of nothing. The stream kept downloading never getting to read. So there has to be something I miss. code sample would be great.
 
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Use OkHttp to get HEADER only. Dont pull stream as it never ends.
I am guessing that the last line "terry pratchett" is the artist and his song name just before it?
NO.
Song name and artist need to be decoded from stream as metadata.

Original Media3/Exoplayer has event for metadata I don't know if it is available in wrapper.

 
Upvote 0
Top