gpt4 book ai didi

ios - 使用AVAUDIOPLAYER从音频流中获取元数据

转载 作者:行者123 更新时间:2023-12-03 01:55:12 26 4
gpt4 key购买 nike

我想使用AVAUDIOPLAYER从音频流中检索元数据(歌曲,艺术家)。我尝试使用此代码,但没有从多个URL获取任何数据。

NSURL *url = [NSURL URLWithString:urlString];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];

for (NSString *format in [asset availableMetadataFormats])

库德有人帮我吗?也许我做错了吗? AVAUDIOPLAYER可以做到吗?

谢谢

最佳答案

这是如何创建AVAsset并使用它创建AVPlayerItem的示例,然后可以将其与AVPlayer实例关联。可以通过使用AVAsset的属性来检索元数据。

var player = AVPlayer()      
func createAssetAndItem(){

//create AVAsset from an NSURL. metadata can be retrieved from the asset depending on what is available
let createdAVAsset = AVURLAsset(URL: songNSURL)

//create an AVPlayerItem from the AVAsset
let createdAVItem = AVPlayerItem(asset: createdAVAsset)

//asscoaite AVPlayerItem with instance of AVPlayer
player = AVPlayer(AVPlayerItem: createdAVItem)


}

关于ios - 使用AVAUDIOPLAYER从音频流中获取元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36221287/

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