问题
I can not get title of song and name of composer on iPhone from HTTP Live Stream (using m3u, m3u8 playlist files). I've tried get it from this site tempomix radio. this is link to streaming - http://stream21.group-network.net:9012
I'm trying use next code:
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
_player = [[AVPlayer playerWithPlayerItem:playerItem] retain];
_player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[_player addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:NULL];
[_player addObserver:self forKeyPath:@"currentItem" options:NSKeyValueObservingOptionNew context:NULL];
[_player addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:NULL];
And then waiting for callback here:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
When callback comes - I check AVPlayerStatus and run play. Radio plays fine - but never comes to observeValueForKeyPath.
I know this question looks similar to this question but described methods don't work for me.
Any ideas? Thanks.
回答1:
ID3 tags have nothing to do with the stream that you linked to. SHOUTcast/Icecast doesn't use ID3 tags.
You will have to parse the SHOUTcast metadata protocol. I've answered this question for PHP here: https://stackoverflow.com/a/4914538/362536 The principals are identical, no matter what the language.
See also http://www.smackfu.com/stuff/programming/shoutcast.html
来源:https://stackoverflow.com/questions/11741388/get-id3-tags-from-stream-on-iphone