gpt4 book ai didi

ios - 用超能力播放 ipod 库中的歌曲

转载 作者:搜寻专家 更新时间:2023-10-30 20:17:02 24 4
gpt4 key购买 nike

自从 Apple 宣布从 2 月 1 日起每个应用程序都必须支持 64 位,我不能再使用 Dirac3LE 了。所以我找到了 Superpowered 似乎也有同样的作用。我目前看到的唯一问题是,我无法让它播放 iPod 库中的歌曲。

我已经尝试通过 AVAssetExportSession 导入歌曲,但无法正常工作。这是我到目前为止尝试过的代码:

NSURL *url = [playingSong valueForProperty:MPMediaItemPropertyAssetURL];

AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:url options:nil];
AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset presetName: AVAssetExportPresetPassthrough];
exporter.outputFileType = @"com.apple.coreaudio-format";
NSString *fname = [[NSString stringWithFormat:@"tmp"] stringByAppendingString:@".mp3"];
NSString *tempPath = NSTemporaryDirectory();
NSString *exportFile = [tempPath stringByAppendingPathComponent: fname];
exporter.outputURL = [NSURL fileURLWithPath:exportFile];
[exporter exportAsynchronouslyWithCompletionHandler:^{
self.player = [[SuperpoweredAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:exportFile]];
[self.player play];
}];

通过以下方式打开文件:

player->open([[url path] fileSystemRepresentation]);

即使这行得通,我还是有点担心这对于音乐播放器来说是否足够快。导入一首歌曲,另一首完成后立即导入。

还有其他选择吗?

谢谢!

最佳答案

如果您有从 iTunes 资料库获取的 MPMediaItem *项目,您可以使用:

player->open([[item assetURL].absoluteString UTF8String]);

关于ios - 用超能力播放 ipod 库中的歌曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26641563/

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