fix: 问题处理~

This commit is contained in:
chengsiwen committed 2026-07-01 18:05:57 +08:00
1 parent a6b0a2ae95
commit fc445e7c80
5 files changed
+206 -38

No files matched your search

@@ -59,6 +59,17 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
oldWidget.currentEpisode != widget.currentEpisode) {
_disposeController();
_initializePlayer();
return;
}
if (oldWidget.autoPlay != widget.autoPlay &&
_controllerCreated &&
_isInitialized) {
if (widget.autoPlay) {
_controller.play();
} else {
_controller.pause();
}
}
}
@@ -70,6 +81,7 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
_currentPosition = Duration.zero;
_totalDuration = Duration.zero;
_isLiked = widget.dramaBean.isCollect ?? false;
_isReportedHis = false;
});
_currentEpisode = _resolveCurrentEpisode();
@@ -105,12 +117,14 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
final videoController = _controller;
final position = videoController.value.position;
final duration = videoController.value.duration;
if (_isPlaying && !_isReportedHis && position.inSeconds > 1) {
if (_isPlaying &&
!_isReportedHis &&
_currentEpisode != null &&
position.inSeconds > 1) {
_isReportedHis = true;
EventClient.eventCreateHis(
shortPlayId: _currentEpisode!.shortPlayId.toString(),
videoId: _currentEpisode!.shortPlayVideoId.toString(),
shortPlayId: _currentEpisode!.shortPlayId.toString(),
videoId: _currentEpisode!.shortPlayVideoId.toString(),
);
}
}
@@ -380,12 +394,12 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
return SizedBox(
width: double.infinity,
height: 3,
height: 28,
child: SliderTheme(
data: SliderThemeData(
trackHeight: 3, // ✅ 进度条高度 3
thumbShape: _ImageThumbShape(imagePath: ConstImg.playTag),
overlayShape: const RoundSliderOverlayShape(overlayRadius: 3),
overlayShape: const RoundSliderOverlayShape(overlayRadius: 10),
activeTrackColor: Colors.white, // ✅ 已播放 = 白色
inactiveTrackColor: Colors.white.withAlpha(126), // ✅ 未播放 = 灰色
thumbColor: Colors.white,
@@ -396,28 +410,46 @@ class _VideoPlayerWidgetState extends State<SkyPlayerView> {
value: progress,
min: 0,
max: 1,
onChangeStart: (_) {
_isSeeking = true;
onChangeStart: (value) {
if (totalMilliseconds <= 0) return;
setState(() {
_isSeeking = true;
_currentPosition = _durationFromProgress(
value,
totalMilliseconds,
);
});
},
onChanged: (value) {
if (totalMilliseconds <= 0) return;
setState(() {
_currentPosition = Duration(
milliseconds: (totalMilliseconds * value).round(),
_currentPosition = _durationFromProgress(
value,
totalMilliseconds,
);
});
},
onChangeEnd: (value) {
final position = Duration(
milliseconds: (totalMilliseconds * value).round(),
);
_controller.seekTo(position);
_isSeeking = false;
if (totalMilliseconds <= 0 || !_controllerCreated) return;
final position = _durationFromProgress(value, totalMilliseconds);
setState(() {
_currentPosition = position;
});
_controller.seekTo(position).whenComplete(() {
if (!mounted) return;
_isSeeking = false;
_syncPlayerValue();
});
},
),
),
);
}
Duration _durationFromProgress(double value, int totalMilliseconds) {
return Duration(milliseconds: (totalMilliseconds * value).round());
}
String _formatDuration(Duration duration) {
final minutes = duration.inMinutes.remainder(60).toString().padLeft(2, '0');
final seconds = duration.inSeconds.remainder(60).toString().padLeft(2, '0');