feat(player): 未就绪改由进度条展示加载态

This commit is contained in:
Zhou Weidong committed 2026-10-21 10:07:34 +08:00
1 parent 76cc52ad66
commit cf4b07aa69
12 files changed
+359 -167

No files matched your search

+13 -5
View File
@@ -12,8 +12,9 @@ void main() {
) async {
await _pumpSurface(tester);
expect(find.byKey(const Key('player-fallback-background')), findsOneWidget);
expect(find.byKey(const Key('player-fallback-cover')), findsOneWidget);
expect(_fallbackColor(tester), Colors.black);
expect(find.byKey(const Key('player-fallback-cover')), findsNothing);
expect(find.byKey(const Key('player-fallback-scrim')), findsNothing);
expect(_opacity(tester), 0);
expect(find.byKey(const Key('player-debug-video')), findsNothing);
});
@@ -48,7 +49,8 @@ void main() {
expect(halfway, lessThan(1));
await tester.pump(const Duration(milliseconds: 100));
expect(_fadeValue(tester), 1);
expect(find.byKey(const Key('player-fallback-background')), findsOneWidget);
expect(_fallbackColor(tester), Colors.black);
expect(find.byKey(const Key('player-fallback-cover')), findsNothing);
expect(find.byKey(const Key('player-debug-video')), findsNothing);
});
@@ -62,7 +64,8 @@ void main() {
expect(find.byKey(const Key('player-video-error')), findsOneWidget);
expect(find.text('No route to host'), findsOneWidget);
expect(find.byKey(const Key('player-fallback-background')), findsOneWidget);
expect(_fallbackColor(tester), Colors.black);
expect(find.byKey(const Key('player-fallback-cover')), findsNothing);
expect(_opacity(tester), 0);
expect(find.byKey(const Key('player-debug-video')), findsNothing);
});
@@ -82,7 +85,6 @@ Future<VideoPlayerController> _pumpSurface(
home: Scaffold(
body: PlayerVideoSurface(
controller: controller,
posterUrl: '/files/poster.jpg',
videoUrl: controller.dataSource,
theater: false,
onTap: () {},
@@ -94,6 +96,12 @@ Future<VideoPlayerController> _pumpSurface(
return controller;
}
Color _fallbackColor(WidgetTester tester) {
return tester
.widget<ColoredBox>(find.byKey(const Key('player-fallback-background')))
.color;
}
double _opacity(WidgetTester tester) {
return tester
.widget<AnimatedOpacity>(find.byKey(const Key('player-video-opacity')))