我想从m3u文件头获取跟踪信息,而不是从id3Tags获取。在AVPlayer的timedMetaData
属性中,仅提供了id3Tag解析。
如何通过AVPlayer跟踪m3u文件获取标题,艺术家,网址等
#EXTM3U
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10,title="Dark Horse",artist="Katy Perry / Juicy J",url="song_spot=\"M\" MediaBaseId=\"1971116\" itunesTrackId=\"0\" amgTrackId=\"-1\" amgArtistId=\"0\" TAID=\"35141\" TPID=\"23894643\" cartcutId=\"0729388001\" amgArtworkURL=\"http://assets.iheart.com/images/1080/MI0003667474\" length=\"00:03:32\" unsID=\"-1\""
http://chunks.ihrhls.com/1469/GqsS8fnz2S6-301028-9984.aac
#EXTINF:10,title="Dark Horse",artist="Katy Perry / Juicy J",url="song_spot=\"M\" MediaBaseId=\"1971116\" itunesTrackId=\"0\" amgTrackId=\"-1\" amgArtistId=\"0\" TAID=\"35141\" TPID=\"23894643\" cartcutId=\"0729388001\" amgArtworkURL=\"http://assets.iheart.com/images/1080/MI0003667474\" length=\"00:03:32\" unsID=\"-1\""
http://chunks.ihrhls.com/1469/spXO68wER45-301029-9984.aac
#EXTINF:10,title="Dark Horse",artist="Katy Perry / Juicy J",url="song_spot=\"M\" MediaBaseId=\"1971116\" itunesTrackId=\"0\" amgTrackId=\"-1\" amgArtistId=\"0\" TAID=\"35141\" TPID=\"23894643\" cartcutId=\"0729388001\" amgArtworkURL=\"http://assets.iheart.com/images/1080/MI0003667474\" length=\"00:03:32\" unsID=\"-1\""
http://chunks.ihrhls.com/1469/RSEeNpIOEHk-301029-10031.aac
答案 0 :(得分:4)
您可以使用AVURLAsset
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL URLWithString:url] options:nil];
NSArray *keys = @[@"playable", @"tracks", @"duration"];
[asset loadValuesAsynchronouslyForKeys:keys completionHandler:^() {
for (NSString *thisKey in keys) {
NSError *error = nil;
AVKeyValueStatus keyStatus = [asset statusOfValueForKey:thisKey error:&error];
if (keyStatus == AVKeyValueStatusFailed) {
//handle error
}
}
}];
另请查看此answer以获取标题,专辑等