Atu*_*uri 8 avaudioplayer ios xcode6
我正在使用AVAudioPlayer播放录制的音频,该音频保存在Iphone的Document目录中.当我第一次录制音频然后播放时,它工作正常(设备连接到系统,应用程序通过Xcode运行).
但是,当我通过Xcode停止正在运行的应用程序并再次通过Xcode运行应用程序时,我收到错误 Error Domain=NSOSStatusErrorDomain Code=2003334207 "The operation couldn’t be completed. (OSStatus error 2003334207.)"
文件位置: file:///var/mobile/Containers/Data/Application/410AB24E-5FB0-4401-AC59-3C03D676E951/Documents/26-06-2015--13:10:47.m4a
我的代码:
fileLocation = @"file:///var/mobile/Containers/Data/Application/410AB24E-5FB0-4401-AC59-3C03D676E951/Documents/26-06-2015--13:10:47.m4a"
NSURL *fileUrl = [NSURL URLWithString:fileLocation];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error];
[player setDelegate:self];
NSURL *fileUrl = [NSURL URLWithString:fileName];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error];
[player setDelegate:self];
Run Code Online (Sandbox Code Playgroud)
我正在使用Xcode 6并在IOS 8中运行App
PS:我已经阅读了很多与此问题相关的文档以及statckoverflow本身的几个问题,但我没有找到答案.
mah*_*udz 14
在iOS8下,您保存的路径在启动时无效.您看到的"410AB24E-5FB0-4401-AC59-3C03D676E951"ID将随每次启动而变化.
解决方案是保存文件名而不是完整路径,并通过获取Documents(或tmp)文件夹的路径并将文件名附加到其中来重新创建URL或完整路径.
| 归档时间: |
|
| 查看次数: |
5084 次 |
| 最近记录: |