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

@@ -4,25 +4,21 @@ 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.posterUrl,
required this.videoUrl,
required this.theater,
required this.onTap,
});
final VideoPlayerController? controller;
final String posterUrl;
final String videoUrl;
final bool theater;
final VoidCallback onTap;
@@ -57,7 +53,10 @@ class _PlayerVideoSurfaceState extends State<PlayerVideoSurface> {
return Stack(
fit: StackFit.expand,
children: [
_FallbackBackground(posterUrl: widget.posterUrl),
const ColoredBox(
key: Key('player-fallback-background'),
color: Colors.black,
),
AnimatedOpacity(
key: const Key('player-video-opacity'),
opacity: reveal ? 1 : 0,
@@ -164,35 +163,3 @@ class _VideoLayer extends StatelessWidget {
);
}
}
class _FallbackBackground extends StatelessWidget {
const _FallbackBackground({required this.posterUrl});
final String posterUrl;
@override
Widget build(BuildContext context) {
if (posterUrl.trim().isEmpty) {
return const ColoredBox(
key: Key('player-fallback-background'),
color: Colors.black,
);
}
return Stack(
key: const Key('player-fallback-background'),
fit: StackFit.expand,
children: [
RemoteImage(
posterUrl,
key: const Key('player-fallback-cover'),
fit: BoxFit.cover,
fallbackColor: Colors.black,
),
const ColoredBox(
key: Key('player-fallback-scrim'),
color: Color(0x4D000000),
),
],
);
}
}