【问题标题】:Play song from ipod library with superpowered播放来自 ipod 库的歌曲,具有超强的功能
【发布时间】:2014-10-29 22:13:04
【问题描述】:

自从 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]);

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

还有其他选择吗?

谢谢!

【问题讨论】:

  • 我也在使用超级强大的 sdk,但我无法进行时间拉伸。请你帮助我好吗?提前致谢
  • 由于我没有在适当的时间让导入工作,我不使用超级动力。如果只是时间拉伸avaudioplayer就足够了。否则你可以考虑 MTAudioProcessingTap 和相应的 AudioUnits。
  • @Dimitri:你找到解决办法了吗?

标签: ios objective-c audio


【解决方案1】:

如果您有一个从 iTunes 库中获得的 MPMediaItem *项目,您可以使用:

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

【讨论】:

  • 传递 mediaItem.assetURL,并用上面的方法打开它可以完美地工作,即使是 Swift 4。
  • 请在上面的行中如何快速书写
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-20
  • 1970-01-01
  • 2012-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多