[英]Getting metadata from a radio stream using MPMoviePlayer? (iOS)
I am using MPMoviePlayer for radio streaming and i need to get the current track info. 我正在使用MPMoviePlayer进行广播,并且需要获取当前的曲目信息。
Can anyone help me as to how I can do this? 有人可以帮我吗?
Firstly, you need to set a NSNotification
so that you can get the data at specific intervals, like so: 首先,您需要设置一个NSNotification
以便您可以按特定的时间间隔获取数据,如下所示:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(StreamMeta:)
name:MPMoviePlayerTimedMetadataUpdatedNotification
object:nil];
Next, you create the method. 接下来,创建方法。 I am going to use streamMPMoviePlayer as the name of your MPMoviePlayerController
and metaString as the NSString
which will store the metadata values: 我将使用streamMPMoviePlayer作为您的名字MPMoviePlayerController
和metaString作为NSString
将存储元数据值:
- (void)StreamMeta:(NSNotification*)notification
{
if ([streamMPMoviePlayer timedMetadata] != nil) {
MPTimedMetadata *meta = [[streamMPMoviePlayer timedMetadata] objectAtIndex:0];
metaString = meta.value; // gives the NSString the artist/song information
}
else {
// No metadata available
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.