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>