fix(home): 频道切换用封面过渡

This commit is contained in:
Zhou Weidong committed 2026-10-21 18:06:09 +08:00
1 parent 838ca2ce2a
commit c9adf8b399
5 files changed
+111 -19

No files matched your search

+2 -1
View File
@@ -378,6 +378,7 @@ class _PlayerPageState extends State<PlayerPage>
PlayerVideoSurface(
controller: videoPort?.controller,
videoUrl: videoPort?.controller.dataSource ?? episode.videoUrl,
posterUrl: drama.posterUrl,
theater: theater,
onTap: () =>
logic.session.setUserWantsPlay(!logic.session.userWantsPlay),
@@ -427,7 +428,7 @@ class _PlayerPageState extends State<PlayerPage>
),
),
),
if (selected && logic.session.loading)
if (selected && logic.session.loading && !widget.homeMode)
const Center(
child: CircularProgressIndicator(
key: Key('player-session-loading'),
@@ -4,22 +4,26 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import '../../../core/widgets/remote_image.dart';
const Duration _videoFadeDuration = Duration(milliseconds: 200);
const double _errorHorizontal = 32;
const int _errorMaxLines = 3;
/// 黑色底层与视频层共用同一控制器,视频首帧就绪后再淡入。
/// 封面或黑色底层与视频层共用同一控制器,视频首帧就绪后再淡入。
class PlayerVideoSurface extends StatefulWidget {
const PlayerVideoSurface({
super.key,
required this.controller,
required this.videoUrl,
this.posterUrl = '',
required this.theater,
required this.onTap,
});
final VideoPlayerController? controller;
final String videoUrl;
final String posterUrl;
final bool theater;
final VoidCallback onTap;
@@ -53,10 +57,17 @@ class _PlayerVideoSurfaceState extends State<PlayerVideoSurface> {
return Stack(
fit: StackFit.expand,
children: [
const ColoredBox(
key: Key('player-fallback-background'),
color: Colors.black,
),
if (widget.posterUrl.isEmpty)
const ColoredBox(
key: Key('player-fallback-background'),
color: Colors.black,
)
else
RemoteImage(
widget.posterUrl,
key: const Key('player-video-poster'),
fit: BoxFit.cover,
),
AnimatedOpacity(
key: const Key('player-video-opacity'),
opacity: reveal ? 1 : 0,