You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Up to version 2.15.1 I used "Player.Listener.onStaticMetadataChanged" to get the IcyHeaders (name, genre, bitrate) for audio streams.
As "Player.Listener.onStaticMetadataChanged" was removed in 2.16.0 none of the recommended replacements (like Player.getMediaMetadata, Player.Listener.onMediaMetadataChanged) seems to contain the IcyHeaders (name, genre, bitrate).
What is the recommended way with 2.16.0 to get the IcyHeaders?
The ICY headers that you'd get in Player.Listener.onStaticMetadataChanged (name, genre, bitrate) are available in Format.metadata which you can get from Player.Listener.onTracksInfoChanged callback (note: Player.Listener.onTracksChanged is deprecated). This snippet should work
@Override
public void onTracksInfoChanged(TracksInfo tracksInfo) {
for (TracksInfo.TrackGroupInfo groupInfo : tracksInfo.getTrackGroupInfos()) {
if (groupInfo.getTrackType() == C.TRACK_TYPE_METADATA) {
TrackGroup group = groupInfo.getTrackGroup();
for (int i = 0; i < group.length; i++) {
// ICY headers will be here.
@Nullable Metadata metadata = group.getFormat(i).metadata;
}
}
}
}
Thanks a lot for your reply. It is working as expected with this implementation:
@Override
public void onTracksInfoChanged(EventTime eventTime, TracksInfo tracksInfo) {
for (TracksInfo.TrackGroupInfo groupInfo : tracksInfo.getTrackGroupInfos()) {
if (groupInfo.getTrackType() == C.TRACK_TYPE_METADATA) {
TrackGroup group = groupInfo.getTrackGroup();
for (int i = 0; i < group.length; i++) {
// ICY headers will be here.
@Nullable Metadata metadata = group.getFormat(i).metadata;
if(metadata != null) {
Log.v("TAG", "onTracksInfoChanged: IcyHeaders = " + metadata.toString());
}
}
}
}
}
Even if this is working it seems not very intuitive to find the IcyHeaders within this callback. May I suggest to implement a separate callback like "onIcyHeaderChanged" or similar?
Anyway, thanks a lot for your support. This question is resolved and can be closed.
Activity
[-]2.16.0: How to get IcyHeaders?[/-][+]r2.16.0: How to get IcyHeaders?[/+]christosts commentedon Nov 11, 2021
The ICY headers that you'd get in
Player.Listener.onStaticMetadataChanged(name, genre, bitrate) are available inFormat.metadatawhich you can get fromPlayer.Listener.onTracksInfoChangedcallback (note:Player.Listener.onTracksChangedis deprecated). This snippet should workLet me know if this worked on your app.
AndreasVogelfrei commentedon Nov 12, 2021
Thanks a lot for your reply. It is working as expected with this implementation:
Even if this is working it seems not very intuitive to find the IcyHeaders within this callback. May I suggest to implement a separate callback like "onIcyHeaderChanged" or similar?
Anyway, thanks a lot for your support. This question is resolved and can be closed.
christosts commentedon Nov 15, 2021
Re-opening to improve how Icy headers are propagated to the app
Populate ICY headers into MediaMetadata
tonihei commentedon Nov 18, 2021
Fixed by the commit above. The ICY headers will appear in
onMetadataChangedasMediaMetadata.stationandMediaMetadata.genre.Populate ICY headers into MediaMetadata
Populate ICY headers into MediaMetadata