我正在尝试获取我的网址的艺术家名称/曲目名称之类的元数据,但是我没有看到,要获得它,我不太确定我缺少什么,音频加载和打得很好:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.mainTitle.text = _stationName;
NSString *u = @"http://pub1.sky.fm:80/sky_solopiano";
NSURL *url = [NSURL URLWithString:u];
radiosound = [[AVPlayer alloc] initWithURL:url];
[radiosound play];
}
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
AVPlayerItem * item = (AVPlayerItem*)object;
NSLog(@"%@", item.timedMetadata);
}
更新 根据此问题中某位成员的建议,我尝试实施
AVAsset *info = radiosound.currentItem.asset;
NSLog(@"%@",info);
而不是
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
AVPlayerItem * item = (AVPlayerItem*)object;
NSLog(@"%@", item.timedMetadata);
}
但是这只返回我已经知道并且不刷新的数据,它当前返回:
<AVURLAsset: 0x109c7ccf0, URL = http://pub1.sky.fm:80/sky_solopiano>
答案 0 :(得分:0)