还是因为音频合成的原因,合成的音频是m4a 格式,上传到七牛后,形成的链接,浏览器可以播放。但是手机不行,m4a 是偏视频格式,用原有的avplayer 方法不能播放,所以需要进行转化后上传播放。
代码如下:
1 | -(void)convetM4aToWav:(NSURL *)originalUrl |
文档目录相关代码如下:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25- (NSString *)documentPath
{
NSString *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
return documentPath;
}
- (NSString *)audioCacheFolder
{
NSString *audioFolder = [[self documentPath] stringByAppendingPathComponent:AUDIOCACHE];
if (![FILEMANAGER fileExistsAtPath:audioFolder]) {
NSError *error = nil;
[FILEMANAGER createDirectoryAtPath:audioFolder withIntermediateDirectories:YES attributes:nil error:&error];
if (error) {
NSLog(@"音频文件夹创建失败----%@", error);
}
}
return audioFolder;
}
//用url作为文件名
- (NSString *)audioFilePath:(NSString *)audioURL
{
NSString *fileName = [audioURL stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
return [[self audioCacheFolder] stringByAppendingPathComponent:fileName];
}