我的流程是这样的,
AVFile *file = [AVFile fileWithData:data name:[NSString stringWithFormat:@"%ld'", time]];
AVIMAudioMessage *message = [AVIMAudioMessage messageWithText:[NSString stringWithFormat:@"%ld''", time] file:file attributes:nil];
[self.conversation sendMessage:message callback:^(BOOL succeeded, NSError *error) {
if (succeeded) {
NSLog(@"发送成功!");
}
}];
....
AVFile *voice = _voiceArray.lastObject;
...
dic[@"video"] = [voice url];
...
NSURL *url = [NSURL URLWithString:dic[@"video"]];
NSData *data = [NSData dataWithContentsOfURL:url];
AVFile *file = [AVFile fileWithData:data name:@"done"];
...
[file getDataInBackgroundWithBlock:^(NSData * _Nullable data, NSError * _Nullable error) {
_audioPlayer = [[AVAudioPlayer alloc]initWithData:data error:&error];
[_audioPlayer setDelegate:self];
[self.audioPlayer play];
}];
大致流程是这样的.我查看了_File 表,也把里面的 url 字段的值.发现上传成功,并且能播放.但我这样用 url 生产的 AVFile 却不能播放,请问是什么原因,要怎么解决.谢谢
补充一下,直接使用 URL 来生产 AVFile *file = [AVFile fileWithRemoteURL:url];也试过了.还是不能播放音频文件
-
创建时间
18年5月28日
-
最后回复
18年5月28日
-
3
回复
-
1.2K
浏览
-
2
用户
-
2
链接