segmentKey static method

  1. @visibleForTesting
String segmentKey(
  1. List<VideoEditorClip> clips,
  2. int i, {
  3. required Size canvas,
  4. required bool hardware,
})

Everything that changes how clip i looks or sounds in the preview, as a stable string. The original file path is used (not the proxy), so a proxy finishing later doesn't invalidate segments.

Implementation

@visibleForTesting
static String segmentKey(
  List<VideoEditorClip> clips,
  int i, {
  required Size canvas,
  required bool hardware,
}) {
  final c = clips[i];
  return jsonEncode([
    c.file.path,
    c.isImage,
    c.isImage ? c.duration.inMilliseconds : c.startTime?.inMilliseconds,
    c.isImage ? null : (c.endTime ?? c.duration).inMilliseconds,
    c.playbackSpeed,
    c.volume,
    c.hasAudio,
    c.audioCleanup.name,
    c.effect.name,
    c.fillMode.name,
    c.cropScale,
    c.cropX,
    c.cropY,
    c.backgroundColor.toARGB32(),
    RenderGraphBuilder.transitionInAt(clips, i).name,
    RenderGraphBuilder.transitionOutAt(clips, i).name,
    canvas.width,
    canvas.height,
    fps,
    hardware,
  ]);
}