2014-02-06 31 views
-1

我已經把那對我來說傳送文件到一個NSArray

- (UIImage *)loadImage:(NSString *)image 
{ 
    // getting the frame of the video for the thumbnail 
    NSString *videoPath = [[NSBundle mainBundle] pathForResource:image ofType:nil]; 
    NSURL *vidURL = [[NSURL alloc] initFileURLWithPath:videoPath]; 
    AVURLAsset *asset = [[AVURLAsset alloc ] initWithURL:vidURL options:nil]; 
    AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset]; 
    NSError *err = NULL; 
    CMTime time = CMTimeMake(1, 30); 
    CGImageRef thumbImg = [generate copyCGImageAtTime:time actualTime:NULL error:&err]; 

    return [[UIImage alloc] initWithCGImage:thumbImg]; 
} 

創建視頻的縮略圖像的方法,現在我有傳送文件列表,我希望放置到數組和地點每個單元格的縮略圖圖像放入單元格中,然後一旦單元格被觸摸,它將轉到detailedViewController並且.mov將開始自動播放。

我的問題是我如何將.mov文件放入一個數組,如果我這樣做上面的方法中的參數之一需要(NSArray *)正確嗎?是/否,還可以幫助我在detailedViewController中播放文件,我需要什麼AVFoundation MPMoviePlayerController。

感謝視頻網址,而不是.MOV文件

+4

不要將媒體文件存儲到數組中,而不要存儲媒體文件url路徑。 – Tirth

+0

你能指點我一個例子的正確方向 – user2257386

+2

這個問題需要很多改進。發佈的代碼示例完全不相關,並且與該問題無關。代碼片段用於從視頻中生成縮略圖,並且您未提及此問題。您列出了您需要做的事情,沒有真正告訴我們您嘗試過什麼,以及您遇到的具體問題與您的一般問題實際相關,只是無法知道您正在做什麼。你需要的是一個教程,你可以像其他人一樣在Google上找到一個教程。 – nhgrif

回答

1

使列表。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *[email protected]"Cell"; 
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    if (cell==nil) { 
     cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 
    } 
    cell.imageView.image=[self loadImage:[arrVideoPath objectAtIndex:indexPath.row]]; 
    return cell 
} 
+0

我如何使網址即時嘗試在網絡上看,但我不能找到它我有31個視頻我已經把它們放到我的項目中的文件夾我只需要看到一個例子,以瞭解它是如何工作的 – user2257386

+0

NSString * stringPath = [[NSBundle mainBundle] pathForResource:@「FOLDER_NAME」ofType:nil]; NSURL * url = [NSURL fileURLWithPath:stringPath]; – user2257386

+0

不使用文件夾名稱使用視頻名稱NSString * strVideo1 = [[NSBundle mainBundle] pathForResource:@「video1」ofType:@「mp4」]; NSURL * url = [NSURL fileURLWithPath:strVideo1]; –