我已經將.mp4文件從服務器下載到文檔目錄,並調用 writeVideoAtPathToSavedPhotosAlbum方法將其保存到圖庫中,但不能正常工作。資產URL nil.Can有人plz幫助我解決這個問題需要將.MP4文件從文檔文件夾保存到照片庫,但資產url返回無
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"test.mp4"];
NSURL *movieURL = [NSURL fileURLWithPath:path];
ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
NSLog(@"Moview URL:%@",movieURL);
NSURL *url = [movieURL copy];
[library writeVideoAtPathToSavedPhotosAlbum:url
completionBlock:^(NSURL *assetURL, NSError *error)
{
NSLog(@"Asset Url:%@",assetURL);
if(!error) {
NSLog(@"\t ! Error");
NSLog(@"\t Error: %@", [error localizedDescription]);
NSLog(@"\t Error code %d", [error code]);
}
if(error != nil) {
NSLog(@"\t ERROR != NIL");
NSLog(@"\t Error - Image Failed To Save With Error: %@", [error localizedDescription]);
NSLog(@"\t Error code %d", [error code]);
}
if(error == nil) {
NSLog(@"\t ERROR == NIL");
}
}];
這是排什麼的日誌: - 的NSLog(@ 「Moview網址:%@」, movieURL);?這裏評論它 – Vizllx
這條線的用途是什麼: - NSURL * url = [movieURL copy]; – Vizllx
url是文檔目錄中視頻位置的資產url – leni