bytes static method

FutureOr<VideoPlayerController> bytes(
  1. Uint8List bytes, {
  2. String? checksum,
  3. VideoPlayerOptions? videoPlayerOptions,
})

Creates a VideoPlayerController from the provided bytes.

Implementation

static FutureOr<VideoPlayerController> bytes(
  Uint8List bytes, {
  String? checksum,
  VideoPlayerOptions? videoPlayerOptions,
}) async {
  final String hash = checksum ?? sha256.convert(bytes).toString();

  final File file = File(
    '${(await PlatformUtils.temporaryDirectory).path}/$hash',
  );

  if (!file.existsSync() || file.lengthSync() != bytes.length) {
    file.writeAsBytesSync(bytes);
  }

  return VideoPlayerController.file(
    file,
    videoPlayerOptions: videoPlayerOptions,
  );
}