createThumbnailUploadVideoFile method

Future<T> createThumbnailUploadVideoFile(
  1. String memberMediumDocumentID,
  2. String filePath, {
  3. FeedbackProgress? feedbackProgress,
})

Implementation

Future<T> createThumbnailUploadVideoFile(
    String memberMediumDocumentID, String filePath,
    {FeedbackProgress? feedbackProgress}) async {
  // First, upload the file
  var fileInfo = await UploadInfo.uploadFile(memberMediumDocumentID, filePath,
      app.documentID, ownerId, packageName, readAccessCustomMetaData(),
      homeURL: app.homeURL,
      feedbackProgress: (progress) => _feedBackAggregatedProgress(
          1, 4, progress,
          feedbackProgress: feedbackProgress));

  // Second, create the thumbnail
  var thumbnailBaseName =
      BaseNameHelper.thumbnailBaseName(memberMediumDocumentID, filePath);
  var enrichedVideo =
      await MediumData.enrichVideoWithPath(memberMediumDocumentID, filePath);
  _feedBackAggregatedProgress(2, 4, 1, feedbackProgress: feedbackProgress);

  // Third, upload the thumbnail;
  var fileInfoThumbnail = await UploadInfo.uploadData(
      thumbnailBaseName,
      enrichedVideo.thumbNailData.data,
      app.documentID,
      ownerId,
      packageName,
      readAccessCustomMetaData(),
      feedbackProgress: (progress) => _feedBackAggregatedProgress(
          3, 4, progress,
          feedbackProgress: feedbackProgress));

  if (fileInfoThumbnail == null) {
    throw Exception(
        'Unable to upload file $filePath. Could not create thumbnail');
  }

  var returnMe = await videoWithThumbnailToMediumModel(
      memberMediumDocumentID,
      enrichedVideo.thumbNailData.baseName,
      fileInfo.item1,
      fileInfoThumbnail,
      enrichedVideo);
  _feedBackAggregatedProgress(4, 4, 1, feedbackProgress: feedbackProgress);
  return returnMe;
}