Description
Searched documentation and issues
I've been looking at the issues in this repository regarding Icy metadata and Shoutcast streams, especially:
- Support non-UTF-8 ICY metadata #6753
- Fetching ICY metadata fails on some streams #5876
- Support ICY metadata #3735
Question
I want to add metadata events to the just_audio Flutter plugin, which uses ExoPlayer in the Android version.
I'm trying to read the IcyInfo and IcyHeaders of a Shoutcast stream. Reading the aforementioned resources, plus this Medium article, I was under the impression that I could retrieve them by adding a MetadataOutput to the current player, like this:
MetadataOutput metadataOutput = new MetadataOutput() {
@Override
public void onMetadata(Metadata metadata) {
Log.d("just_audio", "New metadata. Length: " + metadata.length());
for (int i = 0; i < metadata.length(); i++) {
final Metadata.Entry entry = metadata.get(i);
if (entry instanceof IcyHeaders) {
Log.d("just_audio", "Headers");
} else if (entry instanceof IcyInfo) {
icyTitle = ((IcyInfo) entry).title;
icyUrl = ((IcyInfo) entry).url;
Log.d("just_audio", "Info");
}
broadcastPlaybackEvent();
}
}
};
[...]
player = new SimpleExoPlayer.Builder(context).build();
player.addMetadataOutput(metadataOutput);
[...]
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, "just_audio"));
Uri uri = Uri.parse(url);
mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
player.prepare(mediaSource);
However, I'm receiving events that contain only IcyInfo metadata entries, and I can't figure out why. I've had the same result with several different streams. Am I doing something wrong during initialization?
I'm using ExoPlayer 2.11.4.
Link to test content
I've had the same result with all the Shoutcast streams I've tried. Some examples are:
- http://stream2.mpegradio.com:8070/tormented.mp3
- http://static.207.181.251.148.clients.your-server.de:8000/listen
- http://stream.radyoalaturka.com.tr:9100/test.aac (mentioned in Fetching ICY metadata fails on some streams #5876)
- https://radio.mahoro-net.org/streams/tsumugi (mentioned in Support non-UTF-8 ICY metadata #6753)
The full code I'm using for the Flutter plugin is here: https://github.com/Jei/just_audio/blob/icy-metadata/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java
I'm currently developing a Flutter app on top of it: https://github.com/Jei/tormentedplayer/tree/develop
Activity