2016-07-22 6 views
-1

진행보기가있는 여러 동영상 업로드의 예를 찾습니다. 여기에 단계가 정의되어 있습니다.진행중인 여러 동영상 업로드

  1. 갤러리를 열고 비디오를 선택하십시오.
  2. 갤러리에서 비디오를 선택하고 선택 편집 후, 샘 이미지를 만듭니다.
  3. 테이블 뷰 또는 컬렉션 뷰에서 엄지 손가락 이미지가있는 모든 선택된 비디오 쇼
  4. 진행 상태의 Tableview 또는 Collection 뷰에서 비디오 업로드 프로세스가 표시됩니다.

누구나 그 방법을 알고 있으므로 저에게 도움이 될 것입니다.

우리는 NSUrlsession UPload 작업을 사용할 수 있지만 구현할 수는 없습니다.

이 들어
+0

내 대답을 확인하고 응답 해주십시오. –

답변

1
  1. 당신은 MWPhotoBrowser
  2. 당신이 선택한 비디오의 엄지 손가락 이미지를 생성하는 방법을 아래에 사용할 수 있습니다 사용할 수 있습니다.

    - (UIImage *)generateThumbImage : (NSString *)filepath { 
         NSURL *url = [NSURL fileURLWithPath:filepath]; 
         AVAsset *asset = [AVAsset assetWithURL:url]; 
         AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset]; 
         imageGenerator.appliesPreferredTrackTransform = YES; 
         CMTime time = [asset duration]; 
         time.value = 2; 
         CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:NULL]; 
         UIImage *thumbnail = [UIImage imageWithCGImage:imageRef]; 
         CGImageRelease(imageRef); // CGImageRef won't be released by ARC 
    
         return thumbnail; 
    } 
    
  3. 이렇게하려면 "MWPhotoBrowser"를 확인하고 생성 된 엄지 이미지를 표시 할 수 있습니다.
  4. 이 경우 AFNetworking 3.0을 사용할 수 있습니다. 그리고 모든 파일을 관리하는 하나의 파일 클래스 NSObject을 만듭니다. imageView 및 progressView가있는 collectionView를 만듭니다. 그 collectionView 유형은 파일 유형입니다.

    @interface File : NSObject 
    
    @property (nonatomic, strong) NSString *fullFilePath; 
    @property (nonatomic) float overAllProgress; 
    - (void)sendFile; 
    
    @end 
    
    
    @implementation File 
    
    - (void)sendFile { 
        NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST"   URLString:@"http://localhost/upload.php" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { 
    
        [formData appendPartWithFileURL:[NSURL fileURLWithPath:self.fullFilePath] name:@"photo_path" fileName:self.relativePath mimeType:@"video/quicktime" error:nil]; 
    
        } error:nil]; 
    
        AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 
    
        NSURLSessionUploadTask *uploadTask; 
        uploadTask = [manager 
         uploadTaskWithStreamedRequest:request 
         progress:^(NSProgress * _Nonnull uploadProgress) { 
         // This is not called back on the main queue. 
         // You are responsible for dispatching to the main queue for UI updates 
         dispatch_async(dispatch_get_main_queue(), ^{ 
          //Update the progress view 
          self.overAllProgress = uploadProgress.fractionCompleted; 
          [[NSNotificationCenter defaultCenter] postNotificationName:@"imageprogress" object:self] 
         }); 
         } 
         completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { 
         if (error) { 
          NSLog(@"Error: %@", error); 
         } else { 
          NSLog(@"%@ %@", response, responseObject); 
         } 
         }]; 
    
         [uploadTask resume]; 
    
        @end 
    

이제 파일 진행 알림을 처리해야합니다. 아래처럼.

-(void) viewWillAppear:(BOOL)animated{ 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileProgress:) name:@"imageprogress" object:nil]; 
} 

- (void)viewDidUnload{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"imageprogress" object:nil]; 
} 

- (void)fileProgress:(NSNotification *)notif{ 

     File * info = [notif object]; 
     if([_arrFiles containsObject:info]){ 
      NSInteger row = [_arrFiles indexOfObject:info]; 
      NSIndexPath * indexPath = [NSIndexPath indexPathForRow:row inSection:0]; 
      UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath]; 

     [cell.progressView setProgress:info.overAllProgress animated:YES] 

     } 
} 
+0

안녕하세요 ekta 진행중인 여러 동영상 업로드 관련 샘플 앱이 있습니까? – user1374

+0

아니요, 지금 r8이 없습니다. 그러나 당신은이 단계를 따를 수 있습니다. 그것이 도움이되고 그것이 어떻게 작동하는지 이해할 수 있기를 바랍니다. 질문이 있으시면 언제든지 물어보십시오. –

+0

언급되지 않았습니다. 그냥 upvote을 포기하고 그것이 도움이된다고 생각한다면 받아 들여라. 그것이 나를위한 동기입니다. :디 –