gpt4 book ai didi

ios - 如何用AVPlayer解析m3u文件

转载 作者:技术小花猫 更新时间:2023-10-29 11:24:23 24 4
gpt4 key购买 nike

我想从 m3u 文件头而不是 id3Tags 获取轨道信息。在 AVPlayer 的 timedMetaData 属性中只提供了 id3Tag 解析。

如何使用 AVPlayer 从 m3u 文件中获取标题、艺术家、url 等

#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

最佳答案

您可以使用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获取标题、专辑等。

关于ios - 如何用AVPlayer解析m3u文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29628842/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com