init static method

Future<VideoSource> init({
  1. required String path,
  2. required VideoSourceType type,
  3. Map<String, String>? headers,
})

Initialize a video source.

Implementation

//
//  If the source is an asset, it will be copied to a temporary file.
//
//  [path] is the path to the video source.
//  [type] is the type of video source (asset, file, network).
static Future<VideoSource> init({
  required String path,
  required VideoSourceType type,
  Map<String, String>? headers,
}) async {
  final String sourcePath;
  if (type == VideoSourceType.asset) {
    final tempFile = await loadAssetFile(path);
    sourcePath = tempFile.path;
  } else {
    sourcePath = path;
  }

  headers ??= {};

  return VideoSource(
    path: sourcePath,
    type: type,
    headers: headers,
  );
}