Gitea CI / Assemble and validate CI artifacts (push) Successful in 1m47s
Gitea CI / Check code and tests (push) Successful in 7m15s
Gitea CI / Build Android APK (push) Successful in 4m6s
Gitea CI / Build Windows x64 app (push) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (push) Successful in 1m29s
Gitea CI / Gitea CI passed (push) Successful in 1s
Gitea Release / Prepare draft Release (push) Failing after 8s
Gitea Release / Upload Android to draft Release (push) Skipped
Gitea Release / Upload Windows to draft Release (push) Skipped
Gitea Release / Verify and publish Release (push) Skipped
676 lines
23 KiB
Dart
676 lines
23 KiB
Dart
import 'dart:ui' as ui;
|
|
|
|
import 'package:cutdex_core/timeline/engine.dart';
|
|
import 'package:cutdex_core/timeline/layout.dart';
|
|
import 'package:cutdex_core/timeline/model.dart';
|
|
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
for (final mapping in ['implicit', 'piecewise', 'reverse', 'freeze']) {
|
|
for (final leading in [true, false]) {
|
|
testWidgets(
|
|
'edge trim retains filmstrip samples: $mapping, leading $leading',
|
|
(tester) async {
|
|
final controller = _trimFixture(mapping);
|
|
final frames = _Frames();
|
|
addTearDown(controller.dispose);
|
|
addTearDown(frames.dispose);
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: SizedBox(
|
|
width: 800,
|
|
height: 60,
|
|
child: TimelineView(
|
|
controller: controller,
|
|
thumbnails: frames,
|
|
theme: const TimelineThemeData.dark().copyWith(
|
|
clipHeaderHeight: 20,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final before = frames.requests.map((r) => (r.tick, r.span)).toSet();
|
|
final base = controller.version;
|
|
final viewport = TimelineViewportRect(width: 800, height: 60);
|
|
final down = Offset(leading ? 1 : 599, 40);
|
|
expect(
|
|
controller.beginDrag(
|
|
viewport: viewport,
|
|
position: down,
|
|
trimHitExtent: 6,
|
|
),
|
|
isTrue,
|
|
);
|
|
for (final delta in [0.5, 1.5, 2.5, 6.5, 8.0, 32.5, 123.5, 323.5]) {
|
|
controller.updateDrag(
|
|
viewport: viewport,
|
|
position: down.translate(leading ? delta : -delta, 0),
|
|
);
|
|
await tester.pump();
|
|
expect(controller.dragRejection, isNull);
|
|
expect(frames.requests, isNotEmpty);
|
|
for (final request in frames.requests) {
|
|
expect(
|
|
before,
|
|
contains((request.tick, request.span)),
|
|
reason:
|
|
'The same source cell must retain its sample and sampling tier after $delta px trim',
|
|
);
|
|
}
|
|
}
|
|
controller.updateDrag(
|
|
viewport: viewport,
|
|
position: down.translate(leading ? -8 : 8, 0),
|
|
);
|
|
await tester.pump();
|
|
expect(controller.dragRejection, isNull);
|
|
expect(
|
|
frames.requests.map((r) => (r.tick, r.span)).toSet(),
|
|
containsAll(before),
|
|
reason:
|
|
'Extending an edge reveals cells without replacing old ones',
|
|
);
|
|
controller.cancelDrag();
|
|
await tester.pump();
|
|
expect(controller.version, same(base));
|
|
expect(frames.requests.map((r) => (r.tick, r.span)).toSet(), before);
|
|
expect(
|
|
controller.beginDrag(
|
|
viewport: viewport,
|
|
position: down,
|
|
trimHitExtent: 6,
|
|
),
|
|
isTrue,
|
|
);
|
|
final target = down.translate(leading ? 323.5 : -323.5, 0);
|
|
controller.updateDrag(viewport: viewport, position: target);
|
|
await tester.pump();
|
|
final preview = frames.requests.map((r) => (r.tick, r.span)).toSet();
|
|
expect(
|
|
controller.finishDrag(viewport: viewport, position: target),
|
|
isTrue,
|
|
);
|
|
await tester.pump();
|
|
expect(frames.requests.map((r) => (r.tick, r.span)).toSet(), preview);
|
|
controller.undo();
|
|
await tester.pump();
|
|
expect(frames.requests.map((r) => (r.tick, r.span)).toSet(), before);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
for (final (split, withAudio, retimed) in [
|
|
(false, false, false),
|
|
(false, true, false),
|
|
(true, false, false),
|
|
(true, true, false),
|
|
(true, false, true),
|
|
(true, true, true),
|
|
]) {
|
|
testWidgets(
|
|
'filmstrip and video audio remain separate, withAudio=$withAudio, split=$split, retimed=$retimed',
|
|
(tester) async {
|
|
final kernel = TimelineKernel.importDto(
|
|
TimelineDto(
|
|
id: SequenceId('s'),
|
|
name: 's',
|
|
format: TimelineFormat.fps30,
|
|
primaryStorylineId: StorylineId('p'),
|
|
storylines: [
|
|
StorylineDto(
|
|
id: StorylineId('p'),
|
|
elementIds: [ElementId('a'), ElementId('b')],
|
|
),
|
|
],
|
|
elements: [
|
|
for (final id in ['a', 'b'])
|
|
ElementDto(
|
|
id: ElementId(id),
|
|
structure: ElementStructure.content,
|
|
duration: RationalTime.seconds(10),
|
|
sourceRange: TimeRange(
|
|
start: RationalTime.seconds(5),
|
|
duration: RationalTime.seconds(15),
|
|
),
|
|
mediaRange: TimeRange(
|
|
start: RationalTime.zero,
|
|
duration: RationalTime.seconds(30),
|
|
),
|
|
retimeSegments: retimed
|
|
? [
|
|
RetimeSegmentDto(
|
|
projectDuration: RationalTime.seconds(5),
|
|
sourceStart: RationalTime.seconds(5),
|
|
sourceDelta: RationalTime.seconds(15),
|
|
),
|
|
RetimeSegmentDto(
|
|
projectDuration: RationalTime.seconds(5),
|
|
sourceStart: RationalTime.seconds(20),
|
|
sourceDelta: RationalTime.seconds(-10),
|
|
),
|
|
]
|
|
: [],
|
|
payloadRef: PayloadRef(id),
|
|
name: 'clip',
|
|
),
|
|
],
|
|
),
|
|
);
|
|
final engine = TimelineLayoutEngine(kernel: kernel);
|
|
final projection = const TimelineLayoutSceneBuilder().projectDefinition(
|
|
version: kernel.current,
|
|
definition: kernel.current.query().primaryStoryline,
|
|
sides: const [],
|
|
appearance: (_, _, _) => const LayoutBodyAppearance(
|
|
height: 60,
|
|
domain: LayoutDomainId('video'),
|
|
placementClass: LayoutPlacementClass.visualLike,
|
|
),
|
|
);
|
|
engine.buildComponents(
|
|
kernel: kernel,
|
|
components: TimelineLayoutComponents.build(
|
|
semantic: projection,
|
|
expanded: const [],
|
|
resolve: (_, _, _, _) => const [],
|
|
),
|
|
policy: LayoutPolicy(version: 1, stacks: const []),
|
|
);
|
|
var ids = 0;
|
|
final controller = TimelineViewController.editable(
|
|
engine: engine,
|
|
geometry: TimelineViewportGeometry(primaryTop: 0, primaryHeight: 60),
|
|
camera: TimelineCamera(
|
|
baseTick: 0,
|
|
pixelsPerTick: 60 / TimelineClock.ticksPerSecond,
|
|
),
|
|
createElementId: () => ElementId('split-${ids++}'),
|
|
createConnectionId: () => ConnectionId('link-${ids++}'),
|
|
);
|
|
final frames = _Frames();
|
|
final audio = _VideoAudio();
|
|
addTearDown(audio.dispose);
|
|
final stripHeight = withAudio ? 24.0 : 40.0;
|
|
addTearDown(controller.dispose);
|
|
addTearDown(frames.dispose);
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: SizedBox(
|
|
width: 150,
|
|
height: 60,
|
|
child: TimelineView(
|
|
controller: controller,
|
|
thumbnails: frames,
|
|
waveforms: withAudio ? audio : null,
|
|
theme: const TimelineThemeData.dark().copyWith(
|
|
clipHeaderHeight: 20,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
expect(frames.requests, isNotEmpty);
|
|
expect(frames.requests.every((r) => r.id == 'a'), isTrue);
|
|
expect(
|
|
frames.requests.first.tick,
|
|
((retimed ? 5.0625 : (withAudio ? 4.89375 : 4.78125)) *
|
|
TimelineClock.ticksPerSecond)
|
|
.round(),
|
|
reason:
|
|
'The partial first cell keeps its center, even outside the edit window',
|
|
);
|
|
expect(
|
|
frames.requests.last.tick,
|
|
greaterThan(frames.requests.first.tick),
|
|
);
|
|
expect(
|
|
frames.requests.length,
|
|
withAudio ? 14 : 10,
|
|
reason:
|
|
'Two tiles beyond the visible right edge should be prefetched',
|
|
);
|
|
expect(
|
|
frames.requests.every((r) => r.logicalSize.height == stripHeight),
|
|
isTrue,
|
|
);
|
|
expect(
|
|
frames.requests.every(
|
|
(r) => r.logicalSize.width == stripHeight * 9 / 16,
|
|
),
|
|
isTrue,
|
|
);
|
|
if (!split && !withAudio && !retimed) {
|
|
final published = kernel.current;
|
|
final beforePreview = frames.requests.map((r) => r.tick).toList();
|
|
final handle = published.query().elementById(ElementId('a'))!;
|
|
final preview = const LayoutIntervalEdit().preview(
|
|
kernel: kernel,
|
|
engine: engine,
|
|
projection: engine.currentComponents!.semanticProjection,
|
|
edit: (tx) => tx.retimePlayback(handle, [
|
|
RetimeSegmentDto(
|
|
projectDuration: RationalTime.seconds(5),
|
|
sourceStart: RationalTime.zero,
|
|
sourceDelta: RationalTime.seconds(10),
|
|
),
|
|
]),
|
|
);
|
|
controller.showLayoutPreview(preview.result.version);
|
|
await tester.pump();
|
|
expect(kernel.current, same(published));
|
|
expect(frames.requests.last.tick, greaterThan(beforePreview.last));
|
|
controller.clearLayoutPreview();
|
|
preview.cancel();
|
|
await tester.pump();
|
|
expect(frames.requests.map((r) => r.tick), beforePreview);
|
|
for (final piecewise in [false, true]) {
|
|
final duration =
|
|
(piecewise ? 5 : 10) * TimelineClock.ticksPerSecond + 1;
|
|
final speedPreview = const LayoutIntervalEdit().preview(
|
|
kernel: kernel,
|
|
engine: engine,
|
|
projection: engine.currentComponents!.semanticProjection,
|
|
edit: (tx) => tx.retimePlayback(handle, [
|
|
RetimeSegmentDto(
|
|
projectDuration: RationalTime.timelineTicks(duration),
|
|
sourceStart: RationalTime.zero,
|
|
sourceDelta: RationalTime.seconds(piecewise ? 5 : 10),
|
|
),
|
|
if (piecewise)
|
|
RetimeSegmentDto(
|
|
projectDuration: RationalTime.seconds(5),
|
|
sourceStart: RationalTime.seconds(5),
|
|
sourceDelta: RationalTime.seconds(5),
|
|
),
|
|
]),
|
|
);
|
|
controller.applyLayout(speedPreview.commit());
|
|
for (final scale in [30.0, 60.0, 120.0, 240.0]) {
|
|
controller.setCamera(
|
|
TimelineCamera(
|
|
baseTick: 0,
|
|
pixelsPerTick: scale / TimelineClock.ticksPerSecond,
|
|
),
|
|
);
|
|
await tester.pump();
|
|
final sourceDelta =
|
|
(piecewise ? 7.5 : 15.0) * TimelineClock.ticksPerSecond;
|
|
final sourceTicksPerPixel =
|
|
sourceDelta / duration * TimelineClock.ticksPerSecond / scale;
|
|
final cellSpan = 22.5 * sourceTicksPerPixel;
|
|
final firstCell =
|
|
((5 * TimelineClock.ticksPerSecond + sourceTicksPerPixel) /
|
|
cellSpan)
|
|
.floor();
|
|
expect(
|
|
frames.requests.first.tick,
|
|
closeTo((firstCell + 0.5) * cellSpan, 1),
|
|
reason:
|
|
'Zoom $scale must sample a complete source cell after retiming, piecewise=$piecewise',
|
|
);
|
|
}
|
|
controller.undo();
|
|
}
|
|
controller.setCamera(
|
|
TimelineCamera(
|
|
baseTick: 0,
|
|
pixelsPerTick: 60 / TimelineClock.ticksPerSecond,
|
|
),
|
|
);
|
|
await tester.pump();
|
|
}
|
|
if (split) {
|
|
final before = frames.requests
|
|
.map((request) => (request.tick, request.span))
|
|
.toList();
|
|
controller.panBy(horizontalPixels: 300);
|
|
await tester.pump();
|
|
final beforeRight = frames.requests
|
|
.map((request) => (request.tick, request.span))
|
|
.toList();
|
|
controller.panBy(horizontalPixels: -300);
|
|
await tester.pump();
|
|
controller.seekTo(4 * TimelineClock.ticksPerSecond);
|
|
expect(controller.cutSelectionAtPlayhead(), isTrue);
|
|
await tester.pump();
|
|
expect(
|
|
frames.requests
|
|
.take(before.length)
|
|
.map((request) => (request.tick, request.span)),
|
|
before,
|
|
reason:
|
|
'Splitting outside the visible cells must retain their frames',
|
|
);
|
|
controller.panBy(horizontalPixels: 300);
|
|
await tester.pump();
|
|
expect(frames.requests.first.id, startsWith('split-'));
|
|
expect(
|
|
frames.requests.map((request) => (request.tick, request.span)),
|
|
beforeRight,
|
|
reason: 'The right fragment must keep the original source frames',
|
|
);
|
|
controller.panBy(horizontalPixels: -300);
|
|
controller.undo();
|
|
await tester.pump();
|
|
expect(
|
|
frames.requests.map((request) => (request.tick, request.span)),
|
|
before,
|
|
);
|
|
controller.redo();
|
|
await tester.pump();
|
|
expect(
|
|
frames.requests.map((request) => (request.tick, request.span)),
|
|
before,
|
|
);
|
|
expect(tester.takeException(), isNull);
|
|
await tester.pumpWidget(const SizedBox());
|
|
return;
|
|
}
|
|
final beforeZoom = frames.requests
|
|
.map((request) => request.tick)
|
|
.toList();
|
|
controller.setCamera(
|
|
TimelineCamera(
|
|
baseTick: controller.camera.baseTick,
|
|
fractionalTick: controller.camera.fractionalTick,
|
|
pixelsPerTick: controller.camera.pixelsPerTick * 1.001,
|
|
verticalOffset: controller.camera.verticalOffset,
|
|
),
|
|
);
|
|
await tester.pump();
|
|
expect(frames.requests, hasLength(beforeZoom.length));
|
|
for (var i = 0; i < beforeZoom.length; i++) {
|
|
expect(
|
|
frames.requests[i].tick,
|
|
closeTo(beforeZoom[i], TimelineFormat.fps30.frameGrid.quantumTicks),
|
|
reason:
|
|
'A tiny zoom must shift sample centers by less than a frame',
|
|
);
|
|
}
|
|
final recorder = ui.PictureRecorder();
|
|
Canvas(recorder).drawColor(Colors.red, BlendMode.src);
|
|
final picture = recorder.endRecording();
|
|
frames.image = await tester.runAsync(() => picture.toImage(9, 16));
|
|
picture.dispose();
|
|
frames.ready();
|
|
audio.loaded = true;
|
|
audio.ready();
|
|
await tester.pump();
|
|
final canvas = _ImagesCanvas();
|
|
tester
|
|
.widget<CustomPaint>(find.byType(CustomPaint))
|
|
.painter!
|
|
.paint(canvas, const Size(150, 60));
|
|
expect(
|
|
canvas.destinations.length,
|
|
withAudio ? 12 : 8,
|
|
reason: 'Prefetched tiles must not be painted outside the viewport',
|
|
);
|
|
for (var i = 1; i < canvas.destinations.length; i++) {
|
|
expect(
|
|
canvas.destinations[i].left,
|
|
closeTo(canvas.destinations[i - 1].right, 1e-6),
|
|
reason: 'Portrait thumbnails must fill adjacent tiles without gaps',
|
|
);
|
|
}
|
|
expect(
|
|
canvas.destinations.every(
|
|
(rect) =>
|
|
rect.top >= 20 - 1e-6 && rect.bottom <= 20 + stripHeight + 1e-6,
|
|
),
|
|
isTrue,
|
|
);
|
|
if (withAudio) {
|
|
expect(canvas.bars, isNotEmpty);
|
|
expect(
|
|
canvas.bars.every((bar) => bar.$1.dy >= 46 && bar.$2.dy <= 58),
|
|
isTrue,
|
|
);
|
|
final height = canvas.bars.first.$2.dy - canvas.bars.first.$1.dy;
|
|
audio.gain = 0;
|
|
audio.ready();
|
|
await tester.pump();
|
|
final muted = _ImagesCanvas();
|
|
tester
|
|
.widget<CustomPaint>(find.byType(CustomPaint))
|
|
.painter!
|
|
.paint(muted, const Size(150, 60));
|
|
expect(height, greaterThan(1));
|
|
expect(muted.bars.every((bar) => bar.$2.dy - bar.$1.dy == 1), isTrue);
|
|
}
|
|
final before = frames.requests.map((r) => r.tick).toList();
|
|
controller.panBy(horizontalPixels: 240);
|
|
await tester.pump();
|
|
expect(frames.requests.first.tick, greaterThan(before.first));
|
|
expect(frames.requests.every((r) => r.id == 'a'), isTrue);
|
|
expect(
|
|
kernel.current
|
|
.query()
|
|
.element(kernel.current.query().elementById(ElementId('a'))!)
|
|
.sourceStart,
|
|
5 * TimelineClock.ticksPerSecond,
|
|
);
|
|
expect(tester.takeException(), isNull);
|
|
if (withAudio) {
|
|
audio.bound =
|
|
false; // Audio removed from the video binding after separation.
|
|
audio.ready();
|
|
await tester.pump();
|
|
expect(
|
|
frames.requests.every((r) => r.logicalSize.height == 40),
|
|
isTrue,
|
|
);
|
|
final detached = _ImagesCanvas();
|
|
tester
|
|
.widget<CustomPaint>(find.byType(CustomPaint))
|
|
.painter!
|
|
.paint(detached, const Size(150, 60));
|
|
expect(detached.bars, isEmpty);
|
|
audio.bound = true;
|
|
controller.setGeometry(
|
|
TimelineViewportGeometry(primaryTop: 0, primaryHeight: 40),
|
|
);
|
|
await tester.pump();
|
|
final compact = _ImagesCanvas();
|
|
tester
|
|
.widget<CustomPaint>(find.byType(CustomPaint))
|
|
.painter!
|
|
.paint(compact, const Size(150, 60));
|
|
expect(compact.bars, isEmpty);
|
|
expect(
|
|
frames.requests.every((r) => r.logicalSize.height == 20),
|
|
isTrue,
|
|
);
|
|
}
|
|
await tester.pumpWidget(const SizedBox());
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
TimelineViewController _trimFixture(String mapping) {
|
|
final segments = switch (mapping) {
|
|
'piecewise' => [(5, 5, 5), (5, 10, 10)],
|
|
'reverse' => [(5, 20, -5), (5, 15, -10)],
|
|
'freeze' => [(5, 10, 0), (5, 10, 5)],
|
|
_ => <(int, int, int)>[],
|
|
};
|
|
final kernel = TimelineKernel.importDto(
|
|
TimelineDto(
|
|
id: SequenceId('trim-filmstrip'),
|
|
format: TimelineFormat.fps30,
|
|
primaryStorylineId: StorylineId('p'),
|
|
storylines: [
|
|
StorylineDto(id: StorylineId('p'), elementIds: [ElementId('clip')]),
|
|
],
|
|
elements: [
|
|
ElementDto(
|
|
id: ElementId('clip'),
|
|
structure: ElementStructure.content,
|
|
duration: RationalTime.seconds(10),
|
|
sourceRange: TimeRange(
|
|
start: RationalTime.seconds(mapping == 'freeze' ? 10 : 5),
|
|
duration: RationalTime.seconds(
|
|
mapping == 'implicit'
|
|
? 10
|
|
: mapping == 'freeze'
|
|
? 5
|
|
: 15,
|
|
),
|
|
),
|
|
mediaRange: TimeRange(
|
|
start: RationalTime.zero,
|
|
duration: RationalTime.seconds(30),
|
|
),
|
|
retimeSegments: [
|
|
for (final (duration, start, delta) in segments)
|
|
RetimeSegmentDto(
|
|
projectDuration: RationalTime.seconds(duration),
|
|
sourceStart: RationalTime.seconds(start),
|
|
sourceDelta: RationalTime.seconds(delta),
|
|
),
|
|
],
|
|
payloadRef: PayloadRef('video'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
final projection = const TimelineLayoutSceneBuilder().projectDefinition(
|
|
version: kernel.current,
|
|
definition: kernel.current.query().primaryStoryline,
|
|
sides: const [],
|
|
appearance: (_, _, _) => const LayoutBodyAppearance(
|
|
height: 60,
|
|
domain: LayoutDomainId('video'),
|
|
placementClass: LayoutPlacementClass.visualLike,
|
|
),
|
|
);
|
|
final engine = TimelineLayoutEngine(kernel: kernel);
|
|
engine.buildComponents(
|
|
kernel: kernel,
|
|
components: TimelineLayoutComponents.build(
|
|
semantic: projection,
|
|
expanded: const [],
|
|
resolve: (_, _, _, _) => const [],
|
|
),
|
|
policy: LayoutPolicy(version: 1, stacks: const []),
|
|
);
|
|
var id = 0;
|
|
return TimelineViewController.editable(
|
|
engine: engine,
|
|
geometry: TimelineViewportGeometry(primaryTop: 0, primaryHeight: 60),
|
|
camera: TimelineCamera(
|
|
baseTick: 0,
|
|
pixelsPerTick: 60 / TimelineClock.ticksPerSecond,
|
|
),
|
|
createElementId: () => ElementId('element-${id++}'),
|
|
createConnectionId: () => ConnectionId('connection-${id++}'),
|
|
);
|
|
}
|
|
|
|
class _Frames extends ChangeNotifier implements TimelineThumbnails {
|
|
final requests =
|
|
<
|
|
({
|
|
String id,
|
|
int tick,
|
|
int span,
|
|
Size logicalSize,
|
|
double devicePixelRatio,
|
|
})
|
|
>[];
|
|
ui.Image? image;
|
|
@override
|
|
void beginFrame() => requests.clear();
|
|
@override
|
|
double? aspectRatioFor(ElementRecord element) => 9 / 16;
|
|
@override
|
|
ui.Image? imageFor(
|
|
ElementRecord element,
|
|
int sourceTick, {
|
|
required int sourceSpanTicks,
|
|
required Size logicalSize,
|
|
required double devicePixelRatio,
|
|
}) {
|
|
requests.add((
|
|
id: element.id.value,
|
|
tick: sourceTick,
|
|
span: sourceSpanTicks,
|
|
logicalSize: logicalSize,
|
|
devicePixelRatio: devicePixelRatio,
|
|
));
|
|
return image;
|
|
}
|
|
|
|
@override
|
|
void endFrame() {}
|
|
void ready() => notifyListeners();
|
|
@override
|
|
void dispose() {
|
|
image?.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
class _ImagesCanvas extends TestRecordingCanvas {
|
|
final destinations = <Rect>[];
|
|
final bars = <(Offset, Offset)>[];
|
|
@override
|
|
void drawLine(Offset a, Offset b, Paint paint) {
|
|
if (paint.color.toARGB32() ==
|
|
const TimelineThemeData.dark().audioAccentColor.toARGB32()) {
|
|
bars.add((a, b));
|
|
}
|
|
super.drawLine(a, b, paint);
|
|
}
|
|
|
|
@override
|
|
void drawImageRect(ui.Image image, Rect src, Rect dst, Paint paint) {
|
|
destinations.add(dst);
|
|
super.drawImageRect(image, src, dst, paint);
|
|
}
|
|
}
|
|
|
|
class _VideoAudio extends ChangeNotifier implements TimelineWaveforms {
|
|
bool bound = true;
|
|
bool loaded = false;
|
|
double gain = 1;
|
|
@override
|
|
bool hasAudioFor(ElementRecord element) => bound;
|
|
@override
|
|
void beginFrame() {}
|
|
@override
|
|
void endFrame() {}
|
|
void ready() => notifyListeners();
|
|
@override
|
|
TimelineWaveform? waveformFor(ElementRecord element) => loaded && bound
|
|
? TimelineWaveform(
|
|
sampleRate: 1,
|
|
frameCount: 30,
|
|
amplitudeScale: gain,
|
|
levels: [
|
|
TimelineWaveformLevel(
|
|
samplesPerBucket: 1,
|
|
channels: [
|
|
[
|
|
for (var i = 0; i < 30; i++) ...[-0.5, 0.5, 0.5],
|
|
],
|
|
],
|
|
),
|
|
],
|
|
)
|
|
: null;
|
|
}
|