fix(player): 预热直出并与视频统一封面布局
This commit is contained in:
1 parent
a3a79f7068
commit
48b4e67d34
9 files changed
+119
-104
No files matched your search
@@ -30,7 +30,6 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('player-opening-frame')), findsOneWidget);
|
||||
expect(find.byKey(const Key('fake-opening')), findsOneWidget);
|
||||
expect(_openingOpacity(tester), 1);
|
||||
expect(_opacity(tester), 0);
|
||||
});
|
||||
|
||||
@@ -49,7 +48,7 @@ void main() {
|
||||
expect(find.byKey(const Key('player-opening-frame')), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_cross_fade_video_over_opening_frame', (
|
||||
testWidgets('should_show_cover_until_first_playback_frame', (
|
||||
tester,
|
||||
) async {
|
||||
final controller = await _pumpSurface(
|
||||
@@ -69,7 +68,6 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(_opacity(tester), 0);
|
||||
expect(_openingOpacity(tester), 1);
|
||||
expect(find.byKey(const Key('player-opening-frame')), findsOneWidget);
|
||||
|
||||
controller.value = const VideoPlayerValue(
|
||||
@@ -82,25 +80,36 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(_opacity(tester), 1);
|
||||
expect(find.byKey(const Key('player-opening-frame')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-opening-frame')), findsNothing);
|
||||
expect(
|
||||
tester
|
||||
.widget<AnimatedOpacity>(
|
||||
find.byKey(const Key('player-video-opacity')),
|
||||
)
|
||||
.duration,
|
||||
const Duration(milliseconds: 200),
|
||||
Duration.zero,
|
||||
);
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
final halfway = _fadeValue(tester);
|
||||
expect(halfway, greaterThan(0));
|
||||
expect(halfway, lessThan(1));
|
||||
final openingHalfway = _openingFadeValue(tester);
|
||||
expect(openingHalfway, greaterThan(0));
|
||||
expect(openingHalfway, lessThan(1));
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(_fadeValue(tester), 1);
|
||||
expect(_openingFadeValue(tester), 0);
|
||||
});
|
||||
|
||||
testWidgets('should_skip_cover_when_prewarmed_frame_is_available', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpSurface(
|
||||
tester,
|
||||
openingFrame: const ColoredBox(color: Colors.red),
|
||||
holdOpeningUntilFirstFrame: true,
|
||||
preparedFrameAvailable: true,
|
||||
value: const VideoPlayerValue(
|
||||
duration: Duration(minutes: 1),
|
||||
size: Size(1280, 720),
|
||||
position: Duration.zero,
|
||||
isInitialized: true,
|
||||
isPlaying: false,
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byKey(const Key('player-opening-frame')), findsNothing);
|
||||
expect(_opacity(tester), 1);
|
||||
});
|
||||
|
||||
testWidgets('should_show_video_error_above_retained_fallback', (
|
||||
@@ -147,6 +156,7 @@ void main() {
|
||||
handoff: handoff,
|
||||
videoUrl: current.dataSource,
|
||||
theater: false,
|
||||
openingFrame: const ColoredBox(color: Colors.red),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -155,6 +165,7 @@ void main() {
|
||||
|
||||
await pump(previous);
|
||||
expect(find.byKey(const Key('player-video-handoff')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-opening-frame')), findsNothing);
|
||||
expect(_opacity(tester), 1);
|
||||
|
||||
await pump(null);
|
||||
@@ -168,6 +179,7 @@ Future<VideoPlayerController> _pumpSurface(
|
||||
VideoPlayerValue? value,
|
||||
Widget? openingFrame,
|
||||
bool holdOpeningUntilFirstFrame = false,
|
||||
bool preparedFrameAvailable = false,
|
||||
}) async {
|
||||
final controller = VideoPlayerController.networkUrl(
|
||||
Uri.parse('http://192.168.31.187:8081/files/video.mp4'),
|
||||
@@ -183,6 +195,7 @@ Future<VideoPlayerController> _pumpSurface(
|
||||
theater: false,
|
||||
openingFrame: openingFrame,
|
||||
holdOpeningUntilFirstFrame: holdOpeningUntilFirstFrame,
|
||||
preparedFrameAvailable: preparedFrameAvailable,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -202,27 +215,3 @@ double _opacity(WidgetTester tester) {
|
||||
.widget<AnimatedOpacity>(find.byKey(const Key('player-video-opacity')))
|
||||
.opacity;
|
||||
}
|
||||
|
||||
double _openingOpacity(WidgetTester tester) {
|
||||
return tester
|
||||
.widget<AnimatedOpacity>(
|
||||
find.byKey(const Key('player-opening-frame')),
|
||||
)
|
||||
.opacity;
|
||||
}
|
||||
|
||||
double _fadeValue(WidgetTester tester) {
|
||||
final fade = find.descendant(
|
||||
of: find.byKey(const Key('player-video-opacity')),
|
||||
matching: find.byType(FadeTransition),
|
||||
);
|
||||
return tester.widget<FadeTransition>(fade).opacity.value;
|
||||
}
|
||||
|
||||
double _openingFadeValue(WidgetTester tester) {
|
||||
final fade = find.descendant(
|
||||
of: find.byKey(const Key('player-opening-frame')),
|
||||
matching: find.byType(FadeTransition),
|
||||
);
|
||||
return tester.widget<FadeTransition>(fade).opacity.value;
|
||||
}
|
||||
Reference in new issue
Block a user