import net.pterodactylus.sonitus.data.FormatMetadata;
import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Source;
+import net.pterodactylus.sonitus.data.event.MetadataUpdated;
import net.pterodactylus.sonitus.io.MetadataStream;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
+import com.google.common.eventbus.EventBus;
import com.google.common.primitives.Ints;
/**
*/
public class StreamSource implements Source {
+ /** The event bus. */
+ private final EventBus eventBus;
+
/** The URL of the stream. */
private final String streamUrl;
* the response header for vital information (sampling frequency, number of
* channels, etc.).
*
+ * @param eventBus
+ * The event bus
* @param streamUrl
* The URL of the stream
* @throws IOException
* if an I/O error occurs
*/
- public StreamSource(String streamUrl) throws IOException {
+ public StreamSource(EventBus eventBus, String streamUrl) throws IOException {
+ this.eventBus = eventBus;
this.streamUrl = streamUrl;
URL url = new URL(streamUrl);
return metadata;
}
metadata = metadata.title(streamMetadata.get().title());
+ eventBus.post(new MetadataUpdated(this, metadata));
return metadata;
}