mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: seekTo循环
This commit is contained in:
@@ -102,7 +102,7 @@ class PlPlayerController {
|
|||||||
final RxInt _vttSubtitlesIndex = 0.obs;
|
final RxInt _vttSubtitlesIndex = 0.obs;
|
||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
StreamSubscription<Duration>? _bufferedListenerForSeek;
|
Timer? _timerForSeek;
|
||||||
Timer? _timerForVolume;
|
Timer? _timerForVolume;
|
||||||
Timer? _timerForShowingVolume;
|
Timer? _timerForShowingVolume;
|
||||||
Timer? _timerForGettingVolume;
|
Timer? _timerForGettingVolume;
|
||||||
@@ -153,7 +153,7 @@ class PlPlayerController {
|
|||||||
Stream<bool> get onMuteChanged => _mute.stream;
|
Stream<bool> get onMuteChanged => _mute.stream;
|
||||||
|
|
||||||
// 视频字幕
|
// 视频字幕
|
||||||
RxList<Map<String, String>> get vttSubtitles => _vttSubtitles;
|
RxList<Map<String,String>> get vttSubtitles => _vttSubtitles;
|
||||||
RxInt get vttSubtitlesIndex => _vttSubtitlesIndex;
|
RxInt get vttSubtitlesIndex => _vttSubtitlesIndex;
|
||||||
|
|
||||||
/// [videoPlayerController] instance of Player
|
/// [videoPlayerController] instance of Player
|
||||||
@@ -387,7 +387,7 @@ class PlPlayerController {
|
|||||||
await _initializePlayer(seekTo: seekTo, duration: _duration.value);
|
await _initializePlayer(seekTo: seekTo, duration: _duration.value);
|
||||||
if (videoType.value != 'live') {
|
if (videoType.value != 'live') {
|
||||||
refreshSubtitles().then((value) {
|
refreshSubtitles().then((value) {
|
||||||
if (_vttSubtitles.isNotEmpty) {
|
if (_vttSubtitles.isNotEmpty){
|
||||||
String preference = setting.get(SettingBoxKey.subtitlePreference,
|
String preference = setting.get(SettingBoxKey.subtitlePreference,
|
||||||
defaultValue: SubtitlePreference.values.first.code);
|
defaultValue: SubtitlePreference.values.first.code);
|
||||||
if (preference == 'on') {
|
if (preference == 'on') {
|
||||||
@@ -551,8 +551,8 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> autoEnterFullscreen() async {
|
Future<void> autoEnterFullscreen() async {
|
||||||
bool autoEnterFullscreen = GStrorage.setting
|
bool autoEnterFullscreen =
|
||||||
.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
|
GStrorage.setting.get(SettingBoxKey.enableAutoEnter, defaultValue: false);
|
||||||
if (autoEnterFullscreen) {
|
if (autoEnterFullscreen) {
|
||||||
Future.delayed(const Duration(milliseconds: 500), () {
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
if (dataStatus.status.value != DataStatus.loaded) {
|
if (dataStatus.status.value != DataStatus.loaded) {
|
||||||
@@ -672,20 +672,31 @@ class PlPlayerController {
|
|||||||
_position.value = position;
|
_position.value = position;
|
||||||
updatePositionSecond();
|
updatePositionSecond();
|
||||||
_heartDuration = position.inSeconds;
|
_heartDuration = position.inSeconds;
|
||||||
if (buffered.value == Duration.zero) {
|
if (duration.value.inSeconds != 0) {
|
||||||
_bufferedListenerForSeek?.cancel();
|
|
||||||
_bufferedListenerForSeek = buffered.listen((status) {
|
|
||||||
if (status.inSeconds != 0) {
|
|
||||||
_bufferedListenerForSeek?.cancel();
|
|
||||||
_videoPlayerController?.seek(position);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (type != 'slider') {
|
if (type != 'slider') {
|
||||||
/// 拖动进度条调节时,不等待第一帧,防止抖动
|
/// 拖动进度条调节时,不等待第一帧,防止抖动
|
||||||
await _videoPlayerController?.stream.buffer.first;
|
await _videoPlayerController?.stream.buffer.first;
|
||||||
}
|
}
|
||||||
await _videoPlayerController?.seek(position);
|
await _videoPlayerController?.seek(position);
|
||||||
|
// if (playerStatus.stopped) {
|
||||||
|
// play();
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
print('seek duration else');
|
||||||
|
_timerForSeek?.cancel();
|
||||||
|
_timerForSeek =
|
||||||
|
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
|
||||||
|
//_timerForSeek = null;
|
||||||
|
if (duration.value.inSeconds != 0) {
|
||||||
|
await _videoPlayerController?.stream.buffer.first;
|
||||||
|
await _videoPlayerController?.seek(position);
|
||||||
|
// if (playerStatus.status.value == PlayerStatus.paused) {
|
||||||
|
// play();
|
||||||
|
// }
|
||||||
|
t.cancel();
|
||||||
|
_timerForSeek = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1058,7 +1069,7 @@ class PlPlayerController {
|
|||||||
_timerForVolume?.cancel();
|
_timerForVolume?.cancel();
|
||||||
_timerForGettingVolume?.cancel();
|
_timerForGettingVolume?.cancel();
|
||||||
timerForTrackingMouse?.cancel();
|
timerForTrackingMouse?.cancel();
|
||||||
_bufferedListenerForSeek?.cancel();
|
_timerForSeek?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 记录播放记录
|
// 记录播放记录
|
||||||
@@ -1117,7 +1128,7 @@ class PlPlayerController {
|
|||||||
_timerForVolume?.cancel();
|
_timerForVolume?.cancel();
|
||||||
_timerForGettingVolume?.cancel();
|
_timerForGettingVolume?.cancel();
|
||||||
timerForTrackingMouse?.cancel();
|
timerForTrackingMouse?.cancel();
|
||||||
_bufferedListenerForSeek?.cancel();
|
_timerForSeek?.cancel();
|
||||||
// _position.close();
|
// _position.close();
|
||||||
_playerEventSubs?.cancel();
|
_playerEventSubs?.cancel();
|
||||||
// _sliderPosition.close();
|
// _sliderPosition.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user