up
This commit is contained in:
@@ -13,13 +13,15 @@ class VideoPlayerView extends StatefulWidget {
|
||||
required this.pool,
|
||||
required this.slotIndex,
|
||||
required this.coverUrl,
|
||||
required this.playing,
|
||||
required this.isCurrent,
|
||||
});
|
||||
|
||||
final FeedPlayerPool pool;
|
||||
final int slotIndex;
|
||||
final String coverUrl;
|
||||
final bool playing;
|
||||
|
||||
/// 该页是否为当前页(暂停图标只在当前页显示,避免划走后旧页残留大图标)
|
||||
final bool isCurrent;
|
||||
|
||||
@override
|
||||
State<VideoPlayerView> createState() => _VideoPlayerViewState();
|
||||
@@ -30,6 +32,7 @@ class _VideoPlayerViewState extends State<VideoPlayerView> {
|
||||
Duration _position = Duration.zero;
|
||||
Duration _duration = Duration.zero;
|
||||
bool _seeking = false;
|
||||
double _seekValue = 0; // 拖动中的视觉值(0~1),拖动期间直接控制 painter
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -43,16 +46,26 @@ class _VideoPlayerViewState extends State<VideoPlayerView> {
|
||||
}
|
||||
|
||||
double get _value {
|
||||
if (_seeking) return _seekValue;
|
||||
final total = _duration.inMilliseconds;
|
||||
if (total <= 0) return 0;
|
||||
final cur = _position.inMilliseconds.clamp(0, total);
|
||||
return cur / total;
|
||||
}
|
||||
|
||||
void _onSeekStart(double v) => setState(() => _seeking = true);
|
||||
void _onSeek(double v) => setState(() {});
|
||||
void _onSeekStart(double v) {
|
||||
setState(() {
|
||||
_seeking = true;
|
||||
_seekValue = v;
|
||||
});
|
||||
}
|
||||
|
||||
void _onSeek(double v) {
|
||||
setState(() => _seekValue = v);
|
||||
}
|
||||
|
||||
void _onSeekEnd(double v) {
|
||||
_seeking = false;
|
||||
setState(() => _seeking = false);
|
||||
final totalMs = _duration.inMilliseconds;
|
||||
if (totalMs > 0) {
|
||||
_slot.player.seek(Duration(milliseconds: (v * totalMs).round()));
|
||||
@@ -88,14 +101,22 @@ class _VideoPlayerViewState extends State<VideoPlayerView> {
|
||||
},
|
||||
),
|
||||
|
||||
// 暂停态大播放图标
|
||||
if (!widget.playing)
|
||||
const IgnorePointer(
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
size: 88, color: Colors.white70,
|
||||
),
|
||||
// 暂停态大播放图标:只在当前页、且该槽位确实处于暂停态时显示
|
||||
if (widget.isCurrent)
|
||||
IgnorePointer(
|
||||
child: StreamBuilder<bool>(
|
||||
stream: _slot.player.stream.playing,
|
||||
initialData: _slot.player.state.playing,
|
||||
builder: (_, snapshot) {
|
||||
final playing = snapshot.data ?? false;
|
||||
if (playing) return const SizedBox.shrink();
|
||||
return const Center(
|
||||
child: Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
size: 88, color: Colors.white70,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user