2019-12-06
AudioFileOpenURL
查询 OSStatus错误解释的网站OSStatus
OSStatus错误码参考
CF_ENUM(OSStatus) {
kAudioFileUnspecifiedError = 'wht?', // 0x7768743F, 2003334207
kAudioFileUnsupportedFileTypeError = 'typ?', // 0x7479703F, 1954115647
kAudioFileUnsupportedDataFormatError = 'fmt?', // 0x666D743F, 1718449215
kAudioFileUnsupportedPropertyError = 'pty?', // 0x7074793F, 1886681407
kAudioFileBadPropertySizeError = '!siz', // 0x2173697A, 561211770
kAudioFilePermissionsError = 'prm?', // 0x70726D3F, 1886547263
kAudioFileNotOptimizedError = 'optm', // 0x6F70746D, 1869640813
// file format specific error codes
kAudioFileInvalidChunkError = 'chk?', // 0x63686B3F, 1667787583
kAudioFileDoesNotAllow64BitDataSizeError = 'off?', // 0x6F66663F, 1868981823
kAudioFileInvalidPacketOffsetError = 'pck?', // 0x70636B3F, 1885563711
kAudioFileInvalidFileError = 'dta?', // 0x6474613F, 1685348671
kAudioFileOperationNotSupportedError = 0x6F703F3F, // 'op??', integer used because of trigraph
// general file error codes
kAudioFileNotOpenError = -38,
kAudioFileEndOfFileError = -39,
kAudioFilePositionError = -40,
kAudioFileFileNotFoundError = -43
};
错误代码
let originalURL = Bundle.main.url(forResource: "12345", withExtension: "aac")
var audioFile : AudioFileID? = nil
let osStatus =
AudioFileOpenURL(originalURL as CFURL, .readPermission,0, &audioFile)
if osStatus != noErr {
print("加载失败")
}
报错信息 OSStatus 返回:2003334207
原因:readPermission 权限使用错误
正确的代码
let originalURL = Bundle.main.url(forResource: "12345", withExtension: "aac")
var audioFile : AudioFileID? = nil
let osStatus =
AudioFileOpenURL(originalURL as CFURL, .readPermission,0, &audioFile)
if osStatus != noErr {
print("加载失败")
}