Merge branch 'feature-media_kit' into alpha

This commit is contained in:
guozhigq
2023-10-21 22:16:14 +08:00
3 changed files with 32 additions and 24 deletions

View File

@ -73,6 +73,7 @@ class PlPlayerController {
Rx<bool> videoFitChanged = false.obs;
final Rx<BoxFit> _videoFit = Rx(BoxFit.contain);
final Rx<String> _videoFitDesc = Rx('包含');
///
// ignore: prefer_final_fields
@ -183,6 +184,7 @@ class PlPlayerController {
/// 视频比例
Rx<BoxFit> get videoFit => _videoFit;
Rx<String> get videoFitDEsc => _videoFitDesc;
/// 是否长按倍速
Rx<bool> get doubleSpeedStatus => _doubleSpeedStatus;
@ -445,7 +447,7 @@ class PlPlayerController {
} else {
await setPlaybackSpeed(1.0);
}
getVideoFit();
// if (_looping) {
// await setLooping(_looping);
// }
@ -734,37 +736,34 @@ class PlPlayerController {
if (attrs.indexOf(_videoFit.value) < attrs.length - 1) {
int index = attrs.indexOf(_videoFit.value);
_videoFit.value = attrs[index + 1];
print(videoFitType[index + 1]['desc']);
_videoFitDesc.value = videoFitType[index + 1]['desc'];
SmartDialog.showToast(videoFitType[index + 1]['desc']);
} else {
// 默认 contain
_videoFit.value = videoFitType.first['attr'];
_videoFitDesc.value = videoFitType.first['desc'];
SmartDialog.showToast(videoFitType.first['desc']);
}
videoFitChangedTimer = Timer(const Duration(seconds: 1), () {
videoFitChangedTimer = null;
videoFitChanged.value = false;
});
print(_videoFit.value);
}
/// Change Video Fit accordingly
void onVideoFitChange(BoxFit fit) {
_videoFit.value = fit;
setVideoFit();
}
/// 缓存fit
// Future<void> setVideoFit() async {
// videoStorage.put(VideoBoxKey.videoBrightness, _videoFit.value.name);
// }
Future<void> setVideoFit() async {
List attrs = videoFitType.map((e) => e['attr']).toList();
int index = attrs.indexOf(_videoFit.value);
videoStorage.put(VideoBoxKey.cacheVideoFit, index);
}
/// 读取fit
// Future<void> getVideoFit() async {
// String fitValue =
// videoStorage.get(VideoBoxKey.videoBrightness, defaultValue: 'contain');
// _videoFit.value = videoFitType
// .firstWhere((element) => element['attr'] == fitValue)['attr'];
// }
Future<void> getVideoFit() async {
int fitValue = videoStorage.get(VideoBoxKey.cacheVideoFit, defaultValue: 0);
_videoFit.value = videoFitType[fitValue]['attr'];
_videoFitDesc.value = videoFitType[fitValue]['desc'];
}
/// 读取亮度
// Future<void> getVideoBrightness() async {

View File

@ -115,13 +115,20 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
// ),
// ),
// ),
ComBtn(
icon: const Icon(
Icons.settings_overscan_outlined,
size: 18,
color: Colors.white,
SizedBox(
height: 30,
child: TextButton(
onPressed: () => _.toggleVideoFit(),
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
child: Obx(
() => Text(
_.videoFitDEsc.value,
style: const TextStyle(color: Colors.white, fontSize: 13),
),
),
),
fuc: () => _.toggleVideoFit(),
),
const SizedBox(width: 4),
// 全屏
@ -139,7 +146,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
),
],
),
const SizedBox(height: 10),
const SizedBox(height: 8),
],
),
);

View File

@ -170,4 +170,6 @@ class VideoBoxKey {
static const String longPressSpeedDefault = 'longPressSpeedDefault';
// 自定义倍速集合
static const String customSpeedsList = 'customSpeedsList';
// 画面填充比例
static const String cacheVideoFit = 'cacheVideoFit';
}