美文网首页
2019-12-06

2019-12-06

作者: 红色小星 | 来源:发表于2019-12-06 10:54 被阅读0次

    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("加载失败")
          }
    

    相关文章

      网友评论

          本文标题:2019-12-06

          本文链接:https://www.haomeiwen.com/subject/wibsgctx.html