我目前正在开发一个IP Camera项目。其中一个功能是您可以从相机下载和查看录像。你从相机获得一个网址,下载文件并在应用程序内使用VLC播放。 但是,这些文件位于.avi中,iTunes不支持。是否仍然可以共享.avi文件?当我使用以下代码时:
NSString *urlToDownload = [NSString stringWithFormat:@"%@localhost:%@%@", self.activeRecording.urlProtocol, self.activeCamera.localPort, self.activeRecording.urlQuery];
NSString *fullPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[urlToDownload lastPathComponent]];
NSURL *videoUrl = [NSURL URLWithString:fullPath];
self.activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[videoUrl] applicationActivities:nil];
[self presentViewController:self.activityViewController animated:YES completion:nil];
网址是正确的,因为我可以用它来观看录制。共享菜单打开时,它仅显示“其他”作为选项。我希望能够在Facebook上分享视频和内容,但至少能够使用分享按钮通过电子邮件发送视频。任何人都可以帮助我吗?
tl; dr:想要分享.avi视频,不起作用。
答案 0 :(得分:0)
我目前的解决方案是只允许通过电子邮件与以下代码共享此内容:
NSString *urlToDownload = [NSString stringWithFormat:@"%@localhost:%@%@", self.activeRecording.urlProtocol, self.activeCamera.localPort, self.activeRecording.urlQuery];
NSString *fullPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[urlToDownload lastPathComponent]];
NSData *video = [NSData dataWithContentsOfFile:fullPath];
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:[NSString stringWithFormat:NSLocalizedString(@"%@ recording", @"-name- recording"), self.activeRecording.name]];
[picker addAttachmentData:video mimeType:@"video/avi" fileName:@"recording.avi"];
[self presentViewController:picker animated:YES completion:nil];
如果有人能找到更好的解决方案,那就太棒了。