2011-10-27 30 views
5

Tôi có một ứng dụng mà tôi đang quay video. Nhưng khi ghi xong, tôi không thể lưu video ngay lập tức. Tôi cần phải thể hiện một thỏa thuận trước. Vì vậy, tôi cố gắng lưu URL tôi nhận được từ bộ chọn hình ảnh. Và lưu video vào thư viện sau. Tính năng này hoạt động tốt trong iOS4, nhưng không hoạt động trong iOS5. Tôi mới sử dụng iOS và Objective-C nên có thể tôi đã khai báo hoàn toàn thuộc tính có quyền giữ URL.Lưu trữ URL video đã ghi để lưu vào thư viện sau

này được một số mã:

.h

#import <UIKit/UIKit.h> 
#import <AssetsLibrary/AssetsLibrary.h> 


@interface Video_recViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate> { 

NSURL *tempMoviePath; 

} 


@property (nonatomic, retain) NSURL *tempMoviePath; 

.m

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 

NSURL *moviePath = [info objectForKey:UIImagePickerControllerMediaURL]; 
[self dismissModalViewControllerAnimated: YES]; 
NSLog(@"path from image picker: %@", moviePath); 
tempMoviePath = moviePath; 
NSLog(@"temp movie path: %@", tempMoviePath); 
// 
[self performSelector:@selector(showAgree) withObject:nil afterDelay:0.5]; 

} 

- (void)userAgreed { 
NSLog(@"user agreed"); 
//NSLog(@"temp movie path: %@", tempMoviePath); 
[self saveMyVideo:tempMoviePath]; 
//[self performSelector:@selector(showSurvey) withObject:nil afterDelay:0.5]; 
} 

- (void)saveMyVideo:(NSURL *)videoURL { 

NSLog(@"saving movie at: %@", videoURL); 

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; 
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:videoURL]) 
{ 
    [library writeVideoAtPathToSavedPhotosAlbum:videoURL 
           completionBlock:^(NSURL *assetURL, NSError *error){} 
    ]; 
} 
[library release]; 

} 

Output từ nhật ký khi didFinishPickingMediaWithInfo là:

temp movie path: file://localhost/private/var/mobile/Applications/8CFD1CB7-70A0-465C-B730-817ACE5A4F78/tmp/capture-T0x119660.tmp.hNFzkY/capturedvideo.MOV 

Output từ đăng nhập khi d oing "saveMyVideo". URL đột nhiên biến thành điều này !! :

saving movie at: (
"0.31269", 
"0.32899", 
"0.63999", 
"0.33001", 
"0.3", 
"0.6", 
"0.15", 
"0.05999" 
) 

Trả lời

0

(. Giải đáp của OP trong một câu hỏi chỉnh sửa Xem Question with no answers, but issue solved in the comments (or extended in chat))

Các OP đã viết:

Mã sai là:

tempMoviePath = moviePath; 

Vì tôi đang thiết lập thuộc tính được khai báo, tôi phải se thiết lập các phương thức &. Nó nên là:

[self setTempMoviePath:moviePath]; 

Rõ ràng iOS 4 là không khó khăn như vậy về vấn đề này, nhưng iOS5 không thể xử lý nó. Nhưng, dù sao, nó đã sai bằng văn bản như thế. Tôi thừa nhận sai lầm của tôi. :)

Các vấn đề liên quan