【发布时间】:2013-11-03 03:52:19
【问题描述】:
我正在尝试获取元数据,例如我的 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>
【问题讨论】:
标签: ios objective-c metadata avfoundation avplayer