簡體   English   中英

無法將Instagram視頻下載到相機膠卷

[英]Cannot download Instagram video to camera roll

我正在嘗試學習Instagram API,並且希望能夠將圖像和視頻內容保存到相機膠卷中。 到目前為止,圖像代碼可以正常工作,但是我無法將視頻保存到相機膠卷中。 到目前為止,這是我的代碼

- (void)downloadButtonPressed:(UIButton *)sender {
if ([self.mediaModel.mediaType isEqualToString:@"video"]) {
    NSURL *videoURL = [NSURL URLWithString:_mediaModel.videoStandardResolutionURL];
    if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(videoURL.path)) {
        NSLog(@"compatible");
    } else {
        NSLog(@"not compatible");
    }
    //UISaveVideoAtPathToSavedPhotosAlbum(videoPath, nil, nil, nil);
} else {
    UIImageWriteToSavedPhotosAlbum(self.imageView.image, nil, nil, nil);
}

}

首先,我檢查媒體類型是否為視頻。 如果沒有,那么圖像很容易保存。

如果沒有,我檢查videoURL.path是否兼容,但這是我被卡住的地方,並且出現如下錯誤:

Video /hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4 cannot be saved to the saved photos album: Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo=0x7f8b48f25d00 {NSUnderlyingError=0x7f8b48f39f90 "The operation couldn’t be completed. No such file or directory", NSErrorFailingURLStringKey=file:///hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4, NSErrorFailingURLKey=file:///hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4, NSURL=file:///hphotos-xaf1/t50.2886-16/11803693_1632141970376671_10815617_n.mp4, NSLocalizedDescription=The requested URL was not found on this server.}

非常感謝您的幫助。 非常感謝!

不要嘗試直接從網絡將其保存到已保存的相冊中。 下載它(使用NSURLSession和下載任務)。 然后從那里(即從它為您提供的本地文件URL)將其保存到保存的相冊中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM