ExtAudioConverter音频转换格式

将音频文件比如mp3、caf等音频文件制作为铃声,但是库乐队app需要文件.band的格式才能打开


ExtAudioConverter 讲音频转换成.aiff格式//生成新的BandFilePath

- (NSString*)generateBandFile:(NSString*)filePath{

    NSFileManager *fileManager = [NSFileManager defaultManager];


    NSString *fileName = [[filePath lastPathComponent] stringByDeletingPathExtension];

    NSString* cachePath=[NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) objectAtIndex:0];

    NSString*tmpBandDir = [cachePathstringByAppendingPathComponent:fileName];

    if([fileManagerfileExistsAtPath:tmpBandDir]) {

        [fileManagerremoveItemAtPath:tmpBandDirerror:nil];

    }


    NSString *bandFilePath = [[NSBundle mainBundle] pathForResource:

                              @"bandName"ofType:@"band"];

    if([fileManagerfileExistsAtPath:bandFilePath]){

        [fileManagercopyItemAtPath:bandFilePathtoPath:tmpBandDirerror:nil];

    }


    NSString *ringtonefile = [tmpBandDir stringByAppendingPathComponent:@"Media/ringtone.aiff"];

    ExtAudioConverter* converter = [[ExtAudioConverter alloc] init];

    converter.inputFile= filePath;

    converter.outputFile= ringtonefile;

    converter.outputFileType = kAudioFileAIFFType;

    if([converterconvert]) {

        NSLog(@"转化成功");

    }


    NSString *bandDir = [tmpBandDir stringByAppendingString:@".band"];

    [fileManagermoveItemAtPath:tmpBandDirtoPath:bandDirerror:nil];


    returnbandDir;

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 昨天一天下午还真是个种查,各种搜索,然后各种技术群,各种问,(没人鸟我),其实我是有这个能力的,怎么就一上...
    梦随兴飞阅读 25,220评论 7 18
  • iOS开发-文件管理(一) 一、iOS中的沙盒机制 iOS应用程序只能对自己创建的文件系统读取文件,这个独立、封闭...
    MacShare阅读 5,749评论 0 6
  • 一、iOS中的沙盒机制 iOS应用程序只能对自己创建的文件系统读取文件,这个独立、封闭、安全的空间,叫做沙盒。它一...
    1d5cb7cff98d阅读 5,718评论 0 0
  • 今天开始分析YYCache 包含的文件类 YYCache YYMemoryCache YYDiskCache YY...
    充满活力的早晨阅读 4,185评论 4 1
  • 27、ViewController的didReceiveMemoryWarning是在什么时候调用的?默认的操作是...
    烟雨平生花飞舞阅读 3,788评论 0 1