fix(player): 隔离播放资源所有权并修复黑屏

This commit is contained in:
Zhou Weidong committed 2026-10-26 17:03:19 +08:00
1 parent 54eb5a60a8
commit bb2c729a7e
9 files changed
+223 -25

No files matched your search

+18 -6
View File
@@ -131,7 +131,7 @@ void main() {
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await tester.pumpAndSettle();
final fullPlayer = find.byType(PlayerPage);
final fullPlayer = _fullPlayerFinder();
final fullLogic = _pageLogic(tester, fullPlayer);
expect(fullLogic.session, isNot(same(sourceLogic.session)));
final fullPlayerPort = fullLogic.session.active! as VideoPlayerPort;
@@ -223,11 +223,17 @@ void main() {
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await tester.pumpAndSettle();
expect(find.byType(PlayerPage), findsOneWidget);
expect(_fullPlayerFinder(), findsOneWidget);
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
expect(find.byKey(const Key('home-tabs-bar')), findsNothing);
expect(find.byKey(const Key('recommend-top-nav')), findsNothing);
expect(
find.byKey(const Key('home-feed-center-play')).hitTestable(),
findsNothing,
);
expect(find.byKey(const Key('home-tabs-bar')).hitTestable(), findsNothing);
expect(
find.byKey(const Key('recommend-top-nav')).hitTestable(),
findsNothing,
);
await tester.tap(find.byKey(const Key('player-back')));
await tester.pumpAndSettle();
@@ -259,7 +265,7 @@ void main() {
await tester.tap(find.byKey(const Key('home-feed-full-series')));
await tester.pumpAndSettle();
final fullLogic = _pageLogic(tester, find.byType(PlayerPage));
final fullLogic = _pageLogic(tester, _fullPlayerFinder());
await tester.drag(
find.byKey(const Key('player-video-tap')),
const Offset(0, -560),
@@ -1646,6 +1652,12 @@ PlayerLogic _pageLogic(WidgetTester tester, Finder page) {
return state.logic as PlayerLogic;
}
Finder _fullPlayerFinder() {
return find.byWidgetPredicate(
(widget) => widget is PlayerPage && widget.handoff != null,
);
}
class _RouteVideoFactory {
final List<_RouteVideoPlayer> created = [];
final List<Episode> episodes = [];