Skip to content

Add convenience API for querying static metadata #7266

Closed
@Jei

Description

@Jei

Searched documentation and issues

I've been looking at the issues in this repository regarding Icy metadata and Shoutcast streams, especially:

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions