iPhone: AVAudioPlayer unsupported file type

后端 未结 4 1501
一整个雨季
一整个雨季 2020-11-30 03:00

My app downloads an mp3 from our server and plays it back to the user. The file is 64 kbps (which is well within the acceptable range for iPhone if I understand correctly).

4条回答
  •  一向
    一向 (楼主)
    2020-11-30 03:57

    From iOS 7 AVAudioPlayer has new initializer

    NSError *error;
    [[AVAudioPlayer alloc] initWithData:soundData fileTypeHint:AVFileTypeMPEGLayer3 error:&error]
    

    The supported UTIs

    NSString *const AVFileType3GPP;
    NSString *const AVFileType3GPP2;
    NSString *const AVFileTypeAIFC;
    NSString *const AVFileTypeAIFF;
    NSString *const AVFileTypeAMR;
    NSString *const AVFileTypeAC3;
    NSString *const AVFileTypeMPEGLayer3;
    NSString *const AVFileTypeSunAU;
    NSString *const AVFileTypeCoreAudioFormat;
    NSString *const AVFileTypeAppleM4V;
    NSString *const AVFileTypeMPEG4;
    NSString *const AVFileTypeAppleM4A;
    NSString *const AVFileTypeQuickTimeMovie;
    NSString *const AVFileTypeWAVE;
    

提交回复
热议问题