fix(player): 优化上下滑切集黑屏

This commit is contained in:
Zhou Weidong committed 2026-10-26 13:15:56 +08:00
1 parent b83b5799e3
commit 222bacdeeb
10 files changed
+625 -122

No files matched your search

+39 -9
View File
@@ -13,16 +13,48 @@ void main() {
await _pumpSurface(tester);
expect(_fallbackColor(tester), Colors.black);
expect(find.byKey(const Key('player-fallback-cover')), findsNothing);
expect(find.byKey(const Key('player-fallback-scrim')), findsNothing);
expect(find.byKey(const Key('player-opening-frame')), findsNothing);
expect(_opacity(tester), 0);
expect(find.byKey(const Key('player-debug-video')), findsNothing);
});
testWidgets('should_show_opening_frame_before_decode_is_ready', (
tester,
) async {
await _pumpSurface(
tester,
openingFrame: const ColoredBox(
key: Key('fake-opening'),
color: Colors.red,
),
);
expect(find.byKey(const Key('player-opening-frame')), findsOneWidget);
expect(find.byKey(const Key('fake-opening')), findsOneWidget);
expect(_opacity(tester), 0);
});
testWidgets('should_reveal_paused_frame_when_initialized', (tester) async {
final controller = await _pumpSurface(tester);
controller.value = const VideoPlayerValue(
duration: Duration(minutes: 1),
size: Size(1280, 720),
position: Duration.zero,
isInitialized: true,
isPlaying: false,
);
await tester.pump();
expect(_opacity(tester), 1);
expect(find.byKey(const Key('player-opening-frame')), findsNothing);
});
testWidgets('should_fade_video_in_within_200ms_after_first_frame', (
tester,
) async {
final controller = await _pumpSurface(tester);
final controller = await _pumpSurface(
tester,
openingFrame: const ColoredBox(color: Colors.red),
);
expect(_opacity(tester), 0);
controller.value = const VideoPlayerValue(
@@ -35,6 +67,7 @@ void main() {
await tester.pump();
expect(_opacity(tester), 1);
expect(find.byKey(const Key('player-opening-frame')), findsNothing);
expect(
tester
.widget<AnimatedOpacity>(
@@ -49,9 +82,6 @@ void main() {
expect(halfway, lessThan(1));
await tester.pump(const Duration(milliseconds: 100));
expect(_fadeValue(tester), 1);
expect(_fallbackColor(tester), Colors.black);
expect(find.byKey(const Key('player-fallback-cover')), findsNothing);
expect(find.byKey(const Key('player-debug-video')), findsNothing);
});
testWidgets('should_show_video_error_above_retained_fallback', (
@@ -65,9 +95,7 @@ void main() {
expect(find.byKey(const Key('player-video-error')), findsOneWidget);
expect(find.text('No route to host'), 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);
});
testWidgets('should_cover_new_video_only_while_handoff_is_held', (
@@ -119,6 +147,7 @@ void main() {
Future<VideoPlayerController> _pumpSurface(
WidgetTester tester, {
VideoPlayerValue? value,
Widget? openingFrame,
}) async {
final controller = VideoPlayerController.networkUrl(
Uri.parse('http://192.168.31.187:8081/files/video.mp4'),
@@ -132,6 +161,7 @@ Future<VideoPlayerController> _pumpSurface(
controller: controller,
videoUrl: controller.dataSource,
theater: false,
openingFrame: openingFrame,
),
),
),