[英]Issue getting metadata from stream?
我正在尝试获取URL的元数据,例如艺术家名称/曲目名称,但是我完全看不到,我不确定我丢失了什么,音频加载并正常播放了:
- (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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.