2016-07-22 6 views
-1

進行状況表示付きの複数の動画アップロードの例を検索します。 ここで私はステップを定義しました。進行中の複数のビデオアップロード

  1. ギャラリーを開き、ビデオを選択します。
  2. ギャラリーからビデオを選択し、選択の編集後に、サム画像を作成します。
  3. テーブルビューまたはコレクションビューのサム画像を含むすべての選択されたビデオショー
  4. 進捗状況のあるテーブルビューまたはコレクションビューのビデオアップロードプロセスを示す。

これを行う方法がわかっていれば、私にとっては役に立ちます。

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を使用できます。すべてのファイルを管理するファイルクラスを1つ作成して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を与え、あなたが役に立つと感じたら受け入れてください。それが私のモチベーションです。 :D –

関連する問題