我的流程是这样的,
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];也试过了.还是不能播放音频文件

您好,请问在 [file getDataInBackgroundWithBlock:] 方法是否有返回 error 信息,如果有麻烦粘贴出来。

您好,请问您使用哪个版本的 SDK?

在 9.0 以后的版本中,不支持使用 url 直接下载文件。

下面这篇帖子可以给您参考一下:

想知道,要怎么初始化一个 能正常使用的AVFile.

构建 AVFile 的方法可以参考文档: https://leancloud.cn/docs/leanstorage_guide-objc.html#hash2102686027