如何为 AVAudioPlayer 制作安全的 mp3 文件而不出现错误

Ami*_*neG 0 iphone objective-c avaudioplayer ipad ios

我尝试在 iOS 应用程序上播放某些 mp3 文件时遇到问题。\n首先,我注意到这些文件在 iOS 版 Safari 上也不起作用,但现在我的文件可以在 iOS 版 Safari 上运行,但在我的应用程序上不起作用。

\n\n

我正在使用此代码来播放 mp3 音频文件:

\n\n
NSString *pronociationPath = \xe2\x80\xa6..\n\nif (pronociationPath != nil) \n{           \n    NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:pronociationPath];\n    NSError *error;\n\n    self.player=[[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&error] autorelease];\n    [fileURL release];\n    [self.player setNumberOfLoops:0];\n    if (self.player == nil) {\n        NSLog(@"%@",error);\n    }\n    else\n    {\n        [self.player prepareToPlay];\n        [self.player play];\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我在 Safari iOS 上运行的文件遇到此错误:

\n\n
\n

错误域=NSOSStatusErrorDomain代码=1685348671“操作\n无法完成\xe2\x80\x99。(OSStatus错误1685348671。)”

\n
\n\n

我的代码有问题吗?\n有没有为 iOS 应用程序创建安全 mp3 文件的指南?\n我看过 Apple 文档,但没有看到任何有用的信息https://developer.apple.com/library/archive/documentation/AudioVideo /Conceptual/MultimediaPG/UsingAudio/UsingAudio.html#//apple_ref/doc/uid/TP40009767-CH2-SW28

\n

Raj*_*jan 5

当我尝试在 iOS 4.3 上播放 mp3 文件时,我也收到了相同的错误(OSStatus 错误 1685348671)。

后来发现是mp3声音问题导致在iOS 4.3下不兼容播放。因此,我使用 iTunes Player 将新版本的 mp3 声音与现有的声音进行转换。现在它工作得很好而且更好。

脚步:

  1. 在 iTunes 中打开当前的 mp3 声音
  2. 选择它并单击“高级”菜单>>“创建 MP3 版本”

它将创建当前音频的副本。为您的应用程序使用新创建的 mp3 文件。

它帮助了我。我希望它也可以帮助其他人。一切顺利!