mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 拆分设置,新增音频输出、缓冲区、竖屏扩展显示设置
This commit is contained in:
@@ -1080,7 +1080,7 @@ class _RenderProgressBar extends RenderBox {
|
|||||||
if (total.inMilliseconds == 0) {
|
if (total.inMilliseconds == 0) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
return duration.inMilliseconds / total.inMilliseconds;
|
return (duration.inMilliseconds / total.inMilliseconds).clamp(0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getTimeString(Duration time) {
|
String _getTimeString(Duration time) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'dart:io';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:PiliPalaX/models/video/play/quality.dart';
|
|
||||||
import 'package:PiliPalaX/pages/setting/widgets/select_dialog.dart';
|
import 'package:PiliPalaX/pages/setting/widgets/select_dialog.dart';
|
||||||
import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
||||||
import 'package:PiliPalaX/services/service_locator.dart';
|
import 'package:PiliPalaX/services/service_locator.dart';
|
||||||
@@ -21,10 +20,6 @@ class PlaySetting extends StatefulWidget {
|
|||||||
|
|
||||||
class _PlaySettingState extends State<PlaySetting> {
|
class _PlaySettingState extends State<PlaySetting> {
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
late dynamic defaultVideoQa;
|
|
||||||
late dynamic defaultAudioQa;
|
|
||||||
late dynamic defaultDecode;
|
|
||||||
late dynamic secondDecode;
|
|
||||||
late String defaultSubtitlePreference;
|
late String defaultSubtitlePreference;
|
||||||
late int defaultFullScreenMode;
|
late int defaultFullScreenMode;
|
||||||
late int defaultBtmProgressBehavior;
|
late int defaultBtmProgressBehavior;
|
||||||
@@ -32,14 +27,6 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
defaultVideoQa = setting.get(SettingBoxKey.defaultVideoQa,
|
|
||||||
defaultValue: VideoQuality.values.last.code);
|
|
||||||
defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
|
|
||||||
defaultValue: AudioQuality.values.last.code);
|
|
||||||
defaultDecode = setting.get(SettingBoxKey.defaultDecode,
|
|
||||||
defaultValue: VideoDecodeFormats.values.last.code);
|
|
||||||
secondDecode = setting.get(SettingBoxKey.secondDecode,
|
|
||||||
defaultValue: VideoDecodeFormats.values[1].code);
|
|
||||||
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
||||||
defaultValue: FullScreenMode.values.first.code);
|
defaultValue: FullScreenMode.values.first.code);
|
||||||
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
||||||
@@ -68,7 +55,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
title: Text(
|
title: Text(
|
||||||
'播放设置',
|
'播放器设置',
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -125,6 +112,12 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '竖屏扩大展示',
|
||||||
|
subTitle: '小屏竖屏视频由16:9扩大至5:4展示(!暂不支持临时收起)',
|
||||||
|
setKey: SettingBoxKey.enableVerticalExpand,
|
||||||
|
defaultVal: false,
|
||||||
|
),
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '自动全屏',
|
title: '自动全屏',
|
||||||
subTitle: '视频开始播放时进入全屏',
|
subTitle: '视频开始播放时进入全屏',
|
||||||
@@ -162,134 +155,6 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
setKey: SettingBoxKey.enableOnlineTotal,
|
setKey: SettingBoxKey.enableOnlineTotal,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
ListTile(
|
|
||||||
dense: false,
|
|
||||||
title: Text('默认画质', style: titleStyle),
|
|
||||||
subtitle: Text(
|
|
||||||
'当前画质:${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
|
|
||||||
style: subTitleStyle,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
int? result = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return SelectDialog<int>(
|
|
||||||
title: '默认画质',
|
|
||||||
value: defaultVideoQa,
|
|
||||||
values: VideoQuality.values.reversed.map((e) {
|
|
||||||
return {'title': e.description, 'value': e.code};
|
|
||||||
}).toList());
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (result != null) {
|
|
||||||
defaultVideoQa = result;
|
|
||||||
setting.put(SettingBoxKey.defaultVideoQa, result);
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
dense: false,
|
|
||||||
title: Text('默认音质', style: titleStyle),
|
|
||||||
subtitle: Text(
|
|
||||||
'当前音质:${AudioQualityCode.fromCode(defaultAudioQa)!.description!}',
|
|
||||||
style: subTitleStyle,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
int? result = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return SelectDialog<int>(
|
|
||||||
title: '默认音质',
|
|
||||||
value: defaultAudioQa,
|
|
||||||
values: AudioQuality.values.reversed.map((e) {
|
|
||||||
return {'title': e.description, 'value': e.code};
|
|
||||||
}).toList());
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (result != null) {
|
|
||||||
defaultAudioQa = result;
|
|
||||||
setting.put(SettingBoxKey.defaultAudioQa, result);
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
dense: false,
|
|
||||||
title: Text('首选解码格式', style: titleStyle),
|
|
||||||
subtitle: Text(
|
|
||||||
'首选解码格式:${VideoDecodeFormatsCode.fromCode(defaultDecode)!.description!},请根据设备支持情况与需求调整',
|
|
||||||
style: subTitleStyle,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
String? result = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return SelectDialog<String>(
|
|
||||||
title: '默认解码格式',
|
|
||||||
value: defaultDecode,
|
|
||||||
values: VideoDecodeFormats.values.map((e) {
|
|
||||||
return {'title': e.description, 'value': e.code};
|
|
||||||
}).toList());
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (result != null) {
|
|
||||||
defaultDecode = result;
|
|
||||||
setting.put(SettingBoxKey.defaultDecode, result);
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
dense: false,
|
|
||||||
title: Text('次选解码格式', style: titleStyle),
|
|
||||||
subtitle: Text(
|
|
||||||
'非杜比视频次选:${VideoDecodeFormatsCode.fromCode(secondDecode)!.description!},仍无则选择首个提供的解码格式',
|
|
||||||
style: subTitleStyle,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
String? result = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return SelectDialog<String>(
|
|
||||||
title: '次选解码格式',
|
|
||||||
value: secondDecode,
|
|
||||||
values: VideoDecodeFormats.values.map((e) {
|
|
||||||
return {'title': e.description, 'value': e.code};
|
|
||||||
}).toList());
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (result != null) {
|
|
||||||
secondDecode = result;
|
|
||||||
setting.put(SettingBoxKey.secondDecode, result);
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SetSwitchItem(
|
|
||||||
title: '开启硬解',
|
|
||||||
subTitle: '以较低功耗播放视频,若使用中异常卡死,请尝试关闭',
|
|
||||||
setKey: SettingBoxKey.enableHA,
|
|
||||||
defaultVal: true,
|
|
||||||
),
|
|
||||||
const SetSwitchItem(
|
|
||||||
title: '亮度记忆',
|
|
||||||
subTitle: '返回时自动调整视频亮度',
|
|
||||||
setKey: SettingBoxKey.enableAutoBrightness,
|
|
||||||
defaultVal: false,
|
|
||||||
),
|
|
||||||
const SetSwitchItem(
|
|
||||||
title: '免登录1080P',
|
|
||||||
subTitle: '免登录查看1080P视频',
|
|
||||||
setKey: SettingBoxKey.p1080,
|
|
||||||
defaultVal: true,
|
|
||||||
),
|
|
||||||
const SetSwitchItem(
|
|
||||||
title: 'CDN优化',
|
|
||||||
subTitle: '使用优质CDN线路',
|
|
||||||
setKey: SettingBoxKey.enableCDN,
|
|
||||||
defaultVal: true,
|
|
||||||
),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
title: Text('默认全屏方式', style: titleStyle),
|
title: Text('默认全屏方式', style: titleStyle),
|
||||||
|
|||||||
203
lib/pages/setting/video_setting.dart
Normal file
203
lib/pages/setting/video_setting.dart
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:PiliPalaX/models/video/play/quality.dart';
|
||||||
|
import 'package:PiliPalaX/pages/setting/widgets/select_dialog.dart';
|
||||||
|
import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
||||||
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
|
|
||||||
|
import '../../models/video/play/subtitle.dart';
|
||||||
|
import 'widgets/switch_item.dart';
|
||||||
|
|
||||||
|
class VideoSetting extends StatefulWidget {
|
||||||
|
const VideoSetting({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<VideoSetting> createState() => _VideoSettingState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VideoSettingState extends State<VideoSetting> {
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
late dynamic defaultVideoQa;
|
||||||
|
late dynamic defaultAudioQa;
|
||||||
|
late dynamic defaultDecode;
|
||||||
|
late dynamic secondDecode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
defaultVideoQa = setting.get(SettingBoxKey.defaultVideoQa,
|
||||||
|
defaultValue: VideoQuality.values.last.code);
|
||||||
|
defaultAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
|
||||||
|
defaultValue: AudioQuality.values.last.code);
|
||||||
|
defaultDecode = setting.get(SettingBoxKey.defaultDecode,
|
||||||
|
defaultValue: VideoDecodeFormats.values.last.code);
|
||||||
|
secondDecode = setting.get(SettingBoxKey.secondDecode,
|
||||||
|
defaultValue: VideoDecodeFormats.values[1].code);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
TextStyle titleStyle = Theme.of(context).textTheme.titleMedium!;
|
||||||
|
TextStyle subTitleStyle = Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.copyWith(color: Theme.of(context).colorScheme.outline);
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: false,
|
||||||
|
titleSpacing: 0,
|
||||||
|
title: Text(
|
||||||
|
'音视频设置',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
children: [
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '开启硬解',
|
||||||
|
subTitle: '以较低功耗播放视频,若遇异常卡死,请尝试关闭',
|
||||||
|
setKey: SettingBoxKey.enableHA,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '亮度记忆',
|
||||||
|
subTitle: '返回时自动调整视频亮度',
|
||||||
|
setKey: SettingBoxKey.enableAutoBrightness,
|
||||||
|
defaultVal: false,
|
||||||
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '免登录1080P',
|
||||||
|
subTitle: '免登录查看1080P视频',
|
||||||
|
setKey: SettingBoxKey.p1080,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: 'CDN优化',
|
||||||
|
subTitle: '使用优质CDN线路',
|
||||||
|
setKey: SettingBoxKey.enableCDN,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('默认画质', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'当前画质:${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
int? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<int>(
|
||||||
|
title: '默认画质',
|
||||||
|
value: defaultVideoQa,
|
||||||
|
values: VideoQuality.values.reversed.map((e) {
|
||||||
|
return {'title': e.description, 'value': e.code};
|
||||||
|
}).toList());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
defaultVideoQa = result;
|
||||||
|
setting.put(SettingBoxKey.defaultVideoQa, result);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('默认音质', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'当前音质:${AudioQualityCode.fromCode(defaultAudioQa)!.description!}',
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
int? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<int>(
|
||||||
|
title: '默认音质',
|
||||||
|
value: defaultAudioQa,
|
||||||
|
values: AudioQuality.values.reversed.map((e) {
|
||||||
|
return {'title': e.description, 'value': e.code};
|
||||||
|
}).toList());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
defaultAudioQa = result;
|
||||||
|
setting.put(SettingBoxKey.defaultAudioQa, result);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('首选解码格式', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'首选解码格式:${VideoDecodeFormatsCode.fromCode(defaultDecode)!.description!},请根据设备支持情况与需求调整',
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
String? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<String>(
|
||||||
|
title: '默认解码格式',
|
||||||
|
value: defaultDecode,
|
||||||
|
values: VideoDecodeFormats.values.map((e) {
|
||||||
|
return {'title': e.description, 'value': e.code};
|
||||||
|
}).toList());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
defaultDecode = result;
|
||||||
|
setting.put(SettingBoxKey.defaultDecode, result);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('次选解码格式', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'非杜比视频次选:${VideoDecodeFormatsCode.fromCode(secondDecode)!.description!},仍无则选择首个提供的解码格式',
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
String? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<String>(
|
||||||
|
title: '次选解码格式',
|
||||||
|
value: secondDecode,
|
||||||
|
values: VideoDecodeFormats.values.map((e) {
|
||||||
|
return {'title': e.description, 'value': e.code};
|
||||||
|
}).toList());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
secondDecode = result;
|
||||||
|
setting.put(SettingBoxKey.secondDecode, result);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (Platform.isAndroid)
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '优先使用 OpenSL ES 输出音频',
|
||||||
|
subTitle: '关闭则优先使用AudioTrack输出音频(此项即mpv的--ao)',
|
||||||
|
setKey: SettingBoxKey.useOpenSLES,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '扩大缓冲区',
|
||||||
|
subTitle: '默认缓冲区为视频5MB/直播32MB,开启后为视频32MB/直播64MB,但会延长首次加载时间',
|
||||||
|
setKey: SettingBoxKey.expandBuffer,
|
||||||
|
defaultVal: false,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,23 +33,30 @@ class SettingPage extends StatelessWidget {
|
|||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => Get.toNamed('/recommendSetting'),
|
onTap: () => Get.toNamed('/recommendSetting'),
|
||||||
dense: false,
|
dense: false,
|
||||||
leading: const Icon(Icons.grid_view_outlined),
|
leading: const Icon(Icons.explore_outlined),
|
||||||
title: const Text('推荐流设置'),
|
title: const Text('推荐流设置'),
|
||||||
subtitle: Text('推荐来源(web/app)、刷新保留内容、过滤器', style: subTitleStyle),
|
subtitle: Text('推荐来源(web/app)、刷新保留内容、过滤器', style: subTitleStyle),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => Get.toNamed('/playSetting'),
|
onTap: () => Get.toNamed('/videoSetting'),
|
||||||
leading: const Icon(Icons.play_arrow_outlined),
|
leading: const Icon(Icons.video_settings_outlined),
|
||||||
dense: false,
|
dense: false,
|
||||||
title: const Text('播放设置'),
|
title: const Text('音视频设置'),
|
||||||
subtitle: Text('弹幕、字幕、播放器行为与手势、画质、音质、解码、底部进度条等', style: subTitleStyle),
|
subtitle: Text('画质、音质、解码、缓冲、音频输出等', style: subTitleStyle),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
onTap: () => Get.toNamed('/playSetting'),
|
||||||
|
leading: const Icon(Icons.touch_app_outlined),
|
||||||
|
dense: false,
|
||||||
|
title: const Text('播放器设置'),
|
||||||
|
subtitle: Text('双击/长按、全屏、后台播放、弹幕、字幕、底部进度条等', style: subTitleStyle),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => Get.toNamed('/styleSetting'),
|
onTap: () => Get.toNamed('/styleSetting'),
|
||||||
leading: const Icon(Icons.style_outlined),
|
leading: const Icon(Icons.style_outlined),
|
||||||
dense: false,
|
dense: false,
|
||||||
title: const Text('外观设置'),
|
title: const Text('外观设置'),
|
||||||
subtitle: Text('横屏适配、列宽、首页、主题、字号、图片、动态红点、帧率等', style: subTitleStyle),
|
subtitle: Text('横屏适配(平板)、列宽、首页、主题、字号、图片、动态红点、帧率等', style: subTitleStyle),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => Get.toNamed('/extraSetting'),
|
onTap: () => Get.toNamed('/extraSetting'),
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
late bool autoExitFullcreen;
|
late bool autoExitFullcreen;
|
||||||
late bool autoPlayEnable;
|
late bool autoPlayEnable;
|
||||||
late bool horizontalScreen;
|
late bool horizontalScreen;
|
||||||
|
late bool enableVerticalExpand;
|
||||||
late bool autoPiP;
|
late bool autoPiP;
|
||||||
final Floating floating = Floating();
|
final Floating floating = Floating();
|
||||||
// 生命周期监听
|
// 生命周期监听
|
||||||
@@ -64,6 +65,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
RxBool isFullScreen = false.obs;
|
RxBool isFullScreen = false.obs;
|
||||||
late StreamSubscription<bool> fullScreenStatusListener;
|
late StreamSubscription<bool> fullScreenStatusListener;
|
||||||
late final MethodChannel onUserLeaveHintListener;
|
late final MethodChannel onUserLeaveHintListener;
|
||||||
|
late AnimationController _animationController;
|
||||||
|
late Animation<double> _animation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -91,6 +94,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
autoPlayEnable =
|
autoPlayEnable =
|
||||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||||
autoPiP = setting.get(SettingBoxKey.autoPiP, defaultValue: false);
|
autoPiP = setting.get(SettingBoxKey.autoPiP, defaultValue: false);
|
||||||
|
enableVerticalExpand =
|
||||||
|
setting.get(SettingBoxKey.enableVerticalExpand, defaultValue: false);
|
||||||
videoSourceInit();
|
videoSourceInit();
|
||||||
appbarStreamListen();
|
appbarStreamListen();
|
||||||
// lifecycleListener();
|
// lifecycleListener();
|
||||||
@@ -103,6 +108,19 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// _animationController = AnimationController(
|
||||||
|
// vsync: this,
|
||||||
|
// duration: const Duration(milliseconds: 300),
|
||||||
|
// );
|
||||||
|
// _animation = Tween<double>(
|
||||||
|
// begin: MediaQuery.of(context).orientation == Orientation.landscape
|
||||||
|
// ? context.height
|
||||||
|
// : ((enableVerticalExpand &&
|
||||||
|
// plPlayerController?.direction.value == 'vertical')
|
||||||
|
// ? context.width * 5 / 4
|
||||||
|
// : context.width * 9 / 16),
|
||||||
|
// end: 0,
|
||||||
|
// ).animate(_animationController);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取视频资源,初始化播放器
|
// 获取视频资源,初始化播放器
|
||||||
@@ -233,6 +251,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
videoPlayerServiceHandler.onVideoDetailDispose();
|
videoPlayerServiceHandler.onVideoDetailDispose();
|
||||||
// _lifecycleListener.dispose();
|
// _lifecycleListener.dispose();
|
||||||
showStatusBar();
|
showStatusBar();
|
||||||
|
// _animationController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,12 +360,14 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(
|
||||||
() {
|
() {
|
||||||
final double videoheight = Get.width * 9 / 16;
|
double videoheight = context.width * 9 / 16;
|
||||||
// final double videoheight =
|
final double videowidth = context.width;
|
||||||
// plPlayerController?.direction.value == 'vertical'
|
print(videoDetailController.tabCtr.index);
|
||||||
// ? Get.width
|
if (enableVerticalExpand &&
|
||||||
// : Get.width * 9 / 16;
|
plPlayerController?.direction.value == 'vertical' &&
|
||||||
final double videowidth = Get.width;
|
videoDetailController.tabCtr.index != 1) {
|
||||||
|
videoheight = context.width * 5 / 4;
|
||||||
|
}
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.of(context).orientation ==
|
height: MediaQuery.of(context).orientation ==
|
||||||
Orientation.landscape ||
|
Orientation.landscape ||
|
||||||
@@ -357,7 +378,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
? 0
|
? 0
|
||||||
: MediaQuery.of(context).padding.top)
|
: MediaQuery.of(context).padding.top)
|
||||||
: videoheight,
|
: videoheight,
|
||||||
width: MediaQuery.of(context).size.width,
|
width: context.width,
|
||||||
child: PopScope(
|
child: PopScope(
|
||||||
canPop: isFullScreen.value != true &&
|
canPop: isFullScreen.value != true &&
|
||||||
(horizontalScreen ||
|
(horizontalScreen ||
|
||||||
@@ -514,7 +535,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
Opacity(
|
Opacity(
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: context.width,
|
||||||
height: 0,
|
height: 0,
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => TabBar(
|
() => TabBar(
|
||||||
@@ -598,9 +619,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// 1812x+2176y+1985.68z=680
|
// 1812x+2176y+1985.68z=680
|
||||||
// 1080x+2340y+1589.72z=540
|
// 1080x+2340y+1589.72z=540
|
||||||
final double videoheight =
|
final double videoheight =
|
||||||
sqrt(Get.height * Get.width) * 12.972 -
|
sqrt(context.height * context.width) * 12.972 -
|
||||||
Get.height * 7.928 -
|
context.height * 7.928 -
|
||||||
Get.width * 4.923;
|
context.width * 4.923;
|
||||||
final double videowidth = videoheight * 16 / 9;
|
final double videowidth = videoheight * 16 / 9;
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -608,10 +629,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: isFullScreen.value == true
|
width: isFullScreen.value == true
|
||||||
? Get.width
|
? context.width
|
||||||
: videowidth,
|
: videowidth,
|
||||||
height: isFullScreen.value == true
|
height: isFullScreen.value == true
|
||||||
? Get.height
|
? context.height
|
||||||
: videoheight,
|
: videoheight,
|
||||||
child: PopScope(
|
child: PopScope(
|
||||||
canPop: isFullScreen.value != true,
|
canPop: isFullScreen.value != true,
|
||||||
@@ -758,11 +779,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
))),
|
))),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: isFullScreen.value == true
|
width: isFullScreen.value == true
|
||||||
? Get.width
|
? context.width
|
||||||
: videowidth,
|
: videowidth,
|
||||||
height: isFullScreen.value == true
|
height: isFullScreen.value == true
|
||||||
? 0
|
? 0
|
||||||
: Get.height -
|
: context.height -
|
||||||
videoheight -
|
videoheight -
|
||||||
MediaQuery.of(context).padding.top -
|
MediaQuery.of(context).padding.top -
|
||||||
MediaQuery.of(context).padding.bottom,
|
MediaQuery.of(context).padding.bottom,
|
||||||
@@ -781,11 +802,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: isFullScreen.value == true
|
width: isFullScreen.value == true
|
||||||
? 0
|
? 0
|
||||||
: (Get.width -
|
: (context.width -
|
||||||
MediaQuery.of(context).padding.left -
|
MediaQuery.of(context).padding.left -
|
||||||
MediaQuery.of(context).padding.right -
|
MediaQuery.of(context).padding.right -
|
||||||
videowidth),
|
videowidth),
|
||||||
height: Get.height -
|
height: context.height -
|
||||||
MediaQuery.of(context).padding.top -
|
MediaQuery.of(context).padding.top -
|
||||||
MediaQuery.of(context).padding.bottom,
|
MediaQuery.of(context).padding.bottom,
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
|
|||||||
@@ -429,12 +429,15 @@ class PlPlayerController {
|
|||||||
if (danmakuController != null) {
|
if (danmakuController != null) {
|
||||||
danmakuController!.clear();
|
danmakuController!.clear();
|
||||||
}
|
}
|
||||||
|
int bufferSize =
|
||||||
|
setting.get(SettingBoxKey.expandBuffer, defaultValue: false)
|
||||||
|
? (videoType.value == 'live' ? 64 * 1024 * 1024 : 32 * 1024 * 1024)
|
||||||
|
: (videoType.value == 'live' ? 32 * 1024 * 1024 : 5 * 1024 * 1024);
|
||||||
Player player = _videoPlayerController ??
|
Player player = _videoPlayerController ??
|
||||||
Player(
|
Player(
|
||||||
configuration: PlayerConfiguration(
|
configuration: PlayerConfiguration(
|
||||||
// 默认缓存 5M 大小
|
// 默认缓冲 5M 大小
|
||||||
bufferSize:
|
bufferSize: bufferSize,
|
||||||
videoType.value == 'live' ? 32 * 1024 * 1024 : 5 * 1024 * 1024,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -444,8 +447,10 @@ class PlPlayerController {
|
|||||||
// 音量不一致
|
// 音量不一致
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
await pp.setProperty("volume-max", "100");
|
await pp.setProperty("volume-max", "100");
|
||||||
// await pp.setProperty("ao", "audiotrack,opensles");
|
String ao = setting.get(SettingBoxKey.useOpenSLES, defaultValue: true)
|
||||||
await pp.setProperty("ao", "opensles,audiotrack");
|
? "opensles,audiotrack"
|
||||||
|
: "audiotrack,opensles";
|
||||||
|
await pp.setProperty("ao", ao);
|
||||||
}
|
}
|
||||||
// // vo=gpu-next & gpu-context=android & gpu-api=opengl
|
// // vo=gpu-next & gpu-context=android & gpu-api=opengl
|
||||||
// await pp.setProperty("vo", "gpu-next");
|
// await pp.setProperty("vo", "gpu-next");
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import '../pages/setting/pages/home_tabbar_set.dart';
|
|||||||
import '../pages/setting/pages/play_speed_set.dart';
|
import '../pages/setting/pages/play_speed_set.dart';
|
||||||
import '../pages/setting/recommend_setting.dart';
|
import '../pages/setting/recommend_setting.dart';
|
||||||
import '../pages/setting/play_setting.dart';
|
import '../pages/setting/play_setting.dart';
|
||||||
|
import '../pages/setting/video_setting.dart';
|
||||||
import '../pages/setting/privacy_setting.dart';
|
import '../pages/setting/privacy_setting.dart';
|
||||||
import '../pages/setting/style_setting.dart';
|
import '../pages/setting/style_setting.dart';
|
||||||
import '../pages/setting/hidden_settings.dart';
|
import '../pages/setting/hidden_settings.dart';
|
||||||
@@ -111,10 +112,12 @@ class Routes {
|
|||||||
// 二级回复
|
// 二级回复
|
||||||
CustomGetPage(
|
CustomGetPage(
|
||||||
name: '/replyReply', page: () => const VideoReplyReplyPanel()),
|
name: '/replyReply', page: () => const VideoReplyReplyPanel()),
|
||||||
// 推荐设置
|
// 推荐流设置
|
||||||
CustomGetPage(
|
CustomGetPage(
|
||||||
name: '/recommendSetting', page: () => const RecommendSetting()),
|
name: '/recommendSetting', page: () => const RecommendSetting()),
|
||||||
// 播放设置
|
// 音视频设置
|
||||||
|
CustomGetPage(name: '/videoSetting', page: () => const VideoSetting()),
|
||||||
|
// 播放器设置
|
||||||
CustomGetPage(name: '/playSetting', page: () => const PlaySetting()),
|
CustomGetPage(name: '/playSetting', page: () => const PlaySetting()),
|
||||||
// 外观设置
|
// 外观设置
|
||||||
CustomGetPage(name: '/styleSetting', page: () => const StyleSetting()),
|
CustomGetPage(name: '/styleSetting', page: () => const StyleSetting()),
|
||||||
|
|||||||
@@ -87,6 +87,9 @@ class SettingBoxKey {
|
|||||||
defaultToastOp = 'defaultToastOp',
|
defaultToastOp = 'defaultToastOp',
|
||||||
defaultPicQa = 'defaultPicQa',
|
defaultPicQa = 'defaultPicQa',
|
||||||
enableHA = 'enableHA',
|
enableHA = 'enableHA',
|
||||||
|
useOpenSLES = 'useOpenSLES',
|
||||||
|
expandBuffer = 'expandBuffer',
|
||||||
|
enableVerticalExpand = 'enableVerticalExpand',
|
||||||
enableOnlineTotal = 'enableOnlineTotal',
|
enableOnlineTotal = 'enableOnlineTotal',
|
||||||
enableAutoBrightness = 'enableAutoBrightness',
|
enableAutoBrightness = 'enableAutoBrightness',
|
||||||
enableAutoEnter = 'enableAutoEnter',
|
enableAutoEnter = 'enableAutoEnter',
|
||||||
|
|||||||
Reference in New Issue
Block a user