streamMultiple method

Future<List<CloudflareHTTPResponse<CloudflareStreamVideo?>>> streamMultiple({
  1. List<DataTransmit<File>>? contentFromFiles,
  2. List<DataTransmit<String>>? contentFromPaths,
  3. List<DataTransmit<Uint8List>>? contentFromBytes,
  4. List<DataTransmit<String>>? contentFromUrls,
  5. double? thumbnailTimestampPct,
  6. List<String>? allowedOrigins,
  7. bool? requireSignedURLs,
  8. Watermark? watermark,
})

Stream multiple videos by repeatedly calling stream

Implementation

Future<List<CloudflareHTTPResponse<CloudflareStreamVideo?>>> streamMultiple({
  /// Video files to stream
  List<DataTransmit<File>>? contentFromFiles,

  /// Paths to the video files to stream
  List<DataTransmit<String>>? contentFromPaths,

  /// List of video byte array representations to stream
  List<DataTransmit<Uint8List>>? contentFromBytes,

  /// URL list to the videos. Server must be publicly routable and support
  /// HTTP HEAD requests and HTTP GET range requests. Server should respond
  /// to HTTP HEAD requests with a content-range header with the size
  /// of the file.
  ///
  /// e.g: "https://example.com/myvideo.mp4"
  List<DataTransmit<String>>? contentFromUrls,

  /// ONLY AVAILABLE FOR STREAMING CONTENT FROM URL
  /// Timestamp location of thumbnail image calculated as a percentage value
  /// of the video's duration. To convert from a second-wise timestamp to a
  /// percentage, divide the desired timestamp by the total duration of the
  /// video. If this value is not set, the default thumbnail image will be
  /// from 0s of the video.
  ///
  /// default value: 0
  /// min value:0
  /// max value:1
  ///
  /// e.g: 0.529241
  double? thumbnailTimestampPct,

  /// ONLY AVAILABLE FOR STREAMING CONTENT FROM URL
  /// List which origins should be allowed to display the video. Enter
  /// allowed origin domains in an array and use * for wildcard subdomains.
  /// Empty array will allow the video to be viewed on any origin.
  ///
  /// e.g:
  /// [
  ///   "example.com"
  /// ]
  List<String>? allowedOrigins,

  /// ONLY AVAILABLE FOR STREAMING CONTENT FROM URL
  /// Indicates whether the video can be a accessed only using it's UID.
  /// If set to true, a signed token needs to be generated with a signing key
  /// to view the video.
  ///
  /// default value: false
  ///
  /// e.g: true
  bool? requireSignedURLs,

  /// ONLY AVAILABLE FOR STREAMING CONTENT FROM URL
  /// A Watermark object with the id of an existing watermark profile
  /// e.g: Watermark(id: "ea95132c15732412d22c1476fa83f27a")
  Watermark? watermark,
}) async {
  assert(!isBasic, RestAPIService.authorizedRequestAssertMessage);
  assert(
      (contentFromFiles?.isNotEmpty ?? false) ||
          (contentFromPaths?.isNotEmpty ?? false) ||
          (contentFromBytes?.isNotEmpty ?? false) ||
          (contentFromUrls?.isNotEmpty ?? false),
      'One of the contents must be specified.');

  List<CloudflareHTTPResponse<CloudflareStreamVideo?>> responses = [];

  if (contentFromPaths?.isNotEmpty ?? false) {
    contentFromFiles = [];
    for (final content in contentFromPaths!) {
      contentFromFiles.add(DataTransmit<File>(
          data: File(content.data),
          progressCallback: content.progressCallback));
    }
  }
  if (contentFromFiles?.isNotEmpty ?? false) {
    for (final content in contentFromFiles!) {
      final response = await stream(
        contentFromFile: content,
      );
      responses.add(response);
    }
  } else if (contentFromBytes?.isNotEmpty ?? false) {
    for (final content in contentFromBytes!) {
      final response = await stream(
        contentFromBytes: content,
      );
      responses.add(response);
    }
  } else {
    for (final contentFromUrl in contentFromUrls!) {
      final response = await stream(
        contentFromUrl: contentFromUrl,
        thumbnailTimestampPct: thumbnailTimestampPct,
        allowedOrigins: allowedOrigins,
        requireSignedURLs: requireSignedURLs,
        watermark: watermark,
      );
      responses.add(response);
    }
  }
  return responses;
}