Get ID3 tags from stream on iPhone

只谈情不闲聊 提交于 2019-12-11 19:16:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!