ExtAudioConverter音頻轉(zhuǎn)換格式

將音頻文件比如mp3、caf等音頻文件制作為鈴聲,但是庫(kù)樂(lè)隊(duì)app需要文件.band的格式才能打開(kāi)


ExtAudioConverter 講音頻轉(zhuǎn)換成.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(@"轉(zhuǎn)化成功");

? ? }


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

? ? [fileManagermoveItemAtPath:tmpBandDirtoPath:bandDirerror:nil];


? ? returnbandDir;

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 昨天一天下午還真是個(gè)種查,各種搜索,然后各種技術(shù)群,各種問(wèn),(沒(méi)人鳥(niǎo)我),其實(shí)我是有這個(gè)能力的,怎么就一上...
    夢(mèng)隨興飛閱讀 25,317評(píng)論 7 18
  • iOS開(kāi)發(fā)-文件管理(一) 一、iOS中的沙盒機(jī)制 iOS應(yīng)用程序只能對(duì)自己創(chuàng)建的文件系統(tǒng)讀取文件,這個(gè)獨(dú)立、封閉...
    MacShare閱讀 1,862評(píng)論 0 6
  • 一、iOS中的沙盒機(jī)制 iOS應(yīng)用程序只能對(duì)自己創(chuàng)建的文件系統(tǒng)讀取文件,這個(gè)獨(dú)立、封閉、安全的空間,叫做沙盒。它一...
    1d5cb7cff98d閱讀 1,873評(píng)論 0 0
  • 今天開(kāi)始分析YYCache 包含的文件類(lèi) YYCache YYMemoryCache YYDiskCache YY...
    充滿(mǎn)活力的早晨閱讀 914評(píng)論 4 1
  • 27、ViewController的didReceiveMemoryWarning是在什么時(shí)候調(diào)用的?默認(rèn)的操作是...
    煙雨平生花飛舞閱讀 693評(píng)論 0 1

友情鏈接更多精彩內(nèi)容