I am looking for some solution to get metadata information from my stream http://vibesradio.org:8002/ to be displayed in UILabel of an app that I am developing.
Thanks in advance.
I am looking for some solution to get metadata information from my stream http://vibesradio.org:8002/ to be displayed in UILabel of an app that I am developing.
Thanks in advance.
Here is the answer, there were some partial answers here at stack, so I submit complete solution:
First in viewDidLoad we need to add observable metadata object:
[playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:NULL];
Now, all we need is UILabel and a function in order to display the metadata, assuming that the UIlabel nowPlaying is created, we add the following code:
- (void) observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object
change:(NSDictionary*)change context:(void*)context {
if ([keyPath isEqualToString:@"timedMetadata"])
{
playerItem = object;
for (AVMetadataItem* metadata in playerItem.timedMetadata)
{
NSLog(@"\nkey: %@\nkeySpace: %@\ncommonKey: %@\nvalue: %@", [metadata.key description], metadata.keySpace, metadata.commonKey, metadata.stringValue);
NSString *edited = [metadata.stringValue stringByReplacingOccurrencesOfString:@"_" withString:@" "];
self.nowPlaying.text = edited;
}
}
}
And thats it, now you should have your stream info displayed.