Merge branch 'design' into alpha

This commit is contained in:
guozhigq
2023-10-11 23:49:32 +08:00
8 changed files with 367 additions and 52 deletions

View File

@ -55,6 +55,7 @@ class PlPlayerController {
final Rx<int> _playerCount = Rx(0);
final Rx<double> _playbackSpeed = 1.0.obs;
final Rx<double> _longPressSpeed = 2.0.obs;
final Rx<double> _currentVolume = 1.0.obs;
final Rx<double> _currentBrightness = 0.0.obs;
@ -127,6 +128,9 @@ class PlPlayerController {
/// 视频播放速度
double get playbackSpeed => _playbackSpeed.value;
// 长按倍速
double get longPressSpeed => _longPressSpeed.value;
/// 视频缓冲
Rx<Duration> get buffered => _buffered;
Stream<Duration> get onBufferedChanged => _buffered.stream;
@ -209,6 +213,7 @@ class PlPlayerController {
late double opacityVal;
late double fontSizeVal;
late double danmakuSpeedVal;
late List speedsList;
// 播放顺序相关
PlayRepeat playRepeat = PlayRepeat.pause;
@ -236,6 +241,17 @@ class PlPlayerController {
videoStorage.get(VideoBoxKey.playRepeat,
defaultValue: PlayRepeat.pause.value),
);
_playbackSpeed.value =
videoStorage.get(VideoBoxKey.playSpeedDefault, defaultValue: 1.0);
_longPressSpeed.value =
videoStorage.get(VideoBoxKey.longPressSpeedDefault, defaultValue: 2.0);
List speedsListTemp =
videoStorage.get(VideoBoxKey.customSpeedsList, defaultValue: []);
speedsList = List.from(speedsListTemp);
for (var i in PlaySpeed.values) {
speedsList.add(i.value);
}
// _playerEventSubs = onPlayerStatusChanged.listen((PlayerStatus status) {
// if (status == PlayerStatus.playing) {
// WakelockPlus.enable();
@ -293,7 +309,7 @@ class PlPlayerController {
_autoPlay = autoplay;
_looping = looping;
// 初始化视频倍速
_playbackSpeed.value = speed;
// _playbackSpeed.value = speed;
// 初始化数据加载状态
dataStatus.status.value = DataStatus.loading;
// 初始化全屏方向
@ -774,11 +790,10 @@ class PlPlayerController {
return;
}
_doubleSpeedStatus.value = val;
double currentSpeed = playbackSpeed;
if (val) {
setPlaybackSpeed(currentSpeed * 2);
setPlaybackSpeed(longPressSpeed);
} else {
setPlaybackSpeed(currentSpeed / 2);
setPlaybackSpeed(playbackSpeed);
}
}

View File

@ -9,35 +9,18 @@ enum PlaySpeed {
onePointSevenFive,
two,
twoPointTwoFive,
twoPointFive,
twoPointSevenFive,
twhree,
threePointTwoFive,
threePointFive,
threePointSevenFive,
four,
}
extension PlaySpeedExtension on PlaySpeed {
static final List<String> _descList = [
'0.25',
'0.5',
'0.75',
'正常速度',
'1.25',
'1.5',
'2.0倍',
'2.25倍',
'2.5倍',
'2.75倍',
'3.0倍',
'3.25倍',
'3.5倍',
'3.75倍',
'4.0倍'
'0.25',
'0.5',
'0.75',
'正常',
'1.25',
'1.5',
'1.75',
'2.0',
];
get description => _descList[index];
@ -50,14 +33,6 @@ extension PlaySpeedExtension on PlaySpeed {
1.5,
1.75,
2.0,
2.25,
2.5,
2.75,
3.0,
3.25,
3.5,
3.75,
4.0,
];
get value => _valueList[index];
get defaultValue => _valueList[3];