Merge branch 'feature-media_kit'

This commit is contained in:
guozhigq
2023-08-27 12:23:23 +08:00
7 changed files with 112 additions and 115 deletions

View File

@ -209,27 +209,17 @@ class VideoDetailController extends GetxController
if (result['status']) {
data = result['data'];
/// 优先顺序 省流模式 -> 设置中指定质量 -> 当前可选的最高质量
// firstVideo = data.dash!.video!.first;
// videoUrl = firstVideo.baseUrl!;
// //
// currentVideoQa = VideoQualityCode.fromCode(firstVideo.id!)!;
// /// 优先顺序 设置中指定质量 -> 当前可选的最高质量
// AudioItem firstAudio =
// data.dash!.audio!.isNotEmpty ? data.dash!.audio!.first : AudioItem();
// audioUrl = firstAudio.baseUrl ?? '';
List<VideoItem> allVideosList = data.dash!.video!;
try {
// 当前可播放的最高质量视频
int currentHighVideoQa = allVideosList.first.quality!.code;
//
// 使用预设的画质 当前可用的最高质量
int cacheVideoQa = setting.get(SettingBoxKey.defaultVideoQa,
defaultValue: currentHighVideoQa);
int resVideoQa = currentHighVideoQa;
if (cacheVideoQa <= currentHighVideoQa) {
// 如果预设的画质低于当前最高
List<int> numbers = data.acceptQuality!
.where((e) => e <= currentHighVideoQa)
.toList();
@ -250,10 +240,16 @@ class VideoDetailController extends GetxController
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormats.values.last.code))!;
print(currentDecodeFormats.description);
try {
// 当前视频没有对应格式返回第一个
currentDecodeFormats = supportDecodeFormats
.contains(currentDecodeFormats)
bool flag = false;
for (var i in supportDecodeFormats) {
if (i.startsWith(currentDecodeFormats.code)) {
flag = true;
}
}
currentDecodeFormats = flag
? currentDecodeFormats
: VideoDecodeFormatsCode.fromString(supportDecodeFormats.first)!;
} catch (e) {
@ -297,13 +293,6 @@ class VideoDetailController extends GetxController
}
defaultST = Duration(milliseconds: data.lastPlayTime!);
await playerInit();
// await playerInit(
// firstVideo,
// audioUrl,
// defaultST: Duration(milliseconds: data.lastPlayTime!),
// duration: data.timeLength ?? 0,
// );
} else {
if (result['code'] == -404) {
isShowCover.value = false;

View File

@ -167,50 +167,46 @@ class _HeaderControlState extends State<HeaderControl> {
/// 选择倍速
void showSetSpeedSheet() {
showModalBottomSheet(
context: context,
elevation: 0,
backgroundColor: Colors.transparent,
builder: (BuildContext context) {
return Container(
width: double.infinity,
height: 450,
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: const BorderRadius.all(Radius.circular(12)),
),
margin: const EdgeInsets.all(12),
child: Material(
child: ListView(
physics: const NeverScrollableScrollPhysics(),
double currentSpeed = widget.controller!.playbackSpeed;
SmartDialog.show(
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (context) {
return AlertDialog(
title: const Text('播放速度'),
contentPadding: const EdgeInsets.fromLTRB(0, 20, 0, 20),
content: StatefulBuilder(builder: (context, StateSetter setState) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(
height: 45,
child: Center(
child: Text('播放速度'),
),
),
for (var i in playSpeed) ...[
ListTile(
onTap: () {
widget.controller!.setPlaybackSpeed(i.value);
Get.back(result: {'playbackSpeed': i.value});
},
dense: true,
contentPadding: const EdgeInsets.only(left: 20, right: 20),
title: Text(i.description),
trailing: i.value == widget.controller!.playbackSpeed
? Icon(
Icons.done,
color: Theme.of(context).colorScheme.primary,
)
: null,
),
]
Text('$currentSpeed倍'),
Slider(
min: PlaySpeed.values.first.value,
max: PlaySpeed.values.last.value,
value: currentSpeed,
divisions: PlaySpeed.values.length - 1,
label: '${currentSpeed}x',
onChanged: (double val) =>
{setState(() => currentSpeed = val)},
)
],
);
}),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'取消',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
),
TextButton(
onPressed: () async {
await SmartDialog.dismiss();
widget.controller!.setPlaybackSpeed(currentSpeed);
},
child: const Text('确定'),
),
],
);
},
);

View File

@ -2,11 +2,23 @@ enum PlaySpeed {
pointTwoFive,
pointFive,
pointSevenFive,
one,
onePointTwoFive,
onePointFive,
onePointSevenFive,
two
two,
twoPointTwoFive,
twoPointFive,
twoPointSevenFive,
twhree,
threePointTwoFive,
threePointFive,
threePointSevenFive,
four,
}
extension PlaySpeedExtension on PlaySpeed {
@ -17,8 +29,15 @@ extension PlaySpeedExtension on PlaySpeed {
'正常速度',
'1.25倍',
'1.5倍',
'1.75倍',
'2.0倍',
'2.25倍',
'2.5倍',
'2.75倍',
'3.0倍',
'3.25倍',
'3.5倍',
'3.75倍',
'4.0倍'
];
get description => _descList[index];
@ -30,7 +49,15 @@ extension PlaySpeedExtension on PlaySpeed {
1.25,
1.5,
1.75,
2.0
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];

View File

@ -199,22 +199,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
context: Get.context!,
useSafeArea: false,
builder: (context) => Dialog.fullscreen(
child: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
primary: false,
toolbarHeight: 0,
backgroundColor: Colors.black,
systemOverlayStyle: SystemUiOverlayStyle.light,
backgroundColor: Colors.black,
child: PLVideoPlayer(
controller: _,
headerControl: _.headerControl,
),
body: SafeArea(
bottom: false,
child: PLVideoPlayer(
controller: _,
headerControl: _.headerControl,
),
),
),
),
);
if (result == null) {

View File

@ -30,12 +30,12 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
elevation: 0,
scrolledUnderElevation: 0,
primary: false,
toolbarHeight: 73,
toolbarHeight: 85,
automaticallyImplyLeading: false,
titleSpacing: 14,
title: Column(
children: [
const SizedBox(height: 23),
const SizedBox(height: 17),
Obx(
() {
final int value = _.sliderPosition.value.inSeconds;
@ -45,7 +45,7 @@ class BottomControl extends StatelessWidget implements PreferredSizeWidget {
return Container();
}
return Padding(
padding: const EdgeInsets.only(left: 5, right: 5, bottom: 5),
padding: const EdgeInsets.only(left: 7, right: 5, bottom: 6),
child: ProgressBar(
progress: Duration(seconds: value),
buffered: Duration(seconds: buffer),

View File

@ -713,20 +713,20 @@ packages:
dependency: "direct main"
description:
name: media_kit
sha256: "0a89e7037002a62701ec319c375586849f9ef8e681820e1dd4a4ff7b843f7542"
sha256: "66f04934bcadf592f24d829127471e4dc304de8e9bba5795ade2f3e95552ebfc"
url: "https://pub.dev"
source: hosted
version: "1.1.4+1"
version: "1.1.6"
media_kit_libs_android_video:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_android_video
sha256: "142d389bf3efcf8469594a9c7a06a92fc25843fc6c0c3247f76cdcf70b3b29de"
sha256: "498a5062bc5f000bd23ada3be788ea886ab32c52f7a8252dde1264ca019b819b"
url: "https://pub.dev"
source: hosted
version: "1.3.2"
version: "1.3.3"
media_kit_libs_ios_video:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_ios_video
sha256: fed403dc9d54462e51ee80e0cb23c12a53fadea9a8fa18aca2de9054176d1159
@ -734,31 +734,39 @@ packages:
source: hosted
version: "1.1.3"
media_kit_libs_linux:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_linux
sha256: "570bf18ebbd1221caec082657468be05d180510385d3515ec38e0be44fdcc859"
sha256: "3b7c272179639a914dc8a50bf8a3f2df0e9a503bd727c88fab499dbdf6cb1eb8"
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.1.2"
media_kit_libs_macos_video:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_libs_macos_video
sha256: c06e831f3c22a45296d375788d9bc07871b448f8e9ec98d77b11e5e118a83fb2
url: "https://pub.dev"
source: hosted
version: "1.1.3"
media_kit_libs_windows_video:
media_kit_libs_video:
dependency: "direct main"
description:
name: media_kit_libs_windows_video
sha256: f33aabd8414470d99e2c91dd98d605e6a5f1c4b8082dd933c10951bc961b9124
name: media_kit_libs_video
sha256: "48c8ace458f340e6b930c89c48141ea727b80aa0878f7a01904d7d439865f162"
url: "https://pub.dev"
source: hosted
version: "1.0.7"
version: "1.0.0"
media_kit_libs_windows_video:
dependency: transitive
description:
name: media_kit_libs_windows_video
sha256: "923f068344d7d200184e0aaa2597f3de6c05982a3b1f18035d842ab53f2a1350"
url: "https://pub.dev"
source: hosted
version: "1.0.8"
media_kit_native_event_loop:
dependency: "direct main"
dependency: transitive
description:
name: media_kit_native_event_loop
sha256: e37ce6fb5fa71b8cf513c6a6cd591367743a342a385e7da621a047dd8ef6f4a4
@ -769,10 +777,10 @@ packages:
dependency: "direct main"
description:
name: media_kit_video
sha256: e7fcbe426d42a78ad6696f8f557adb9cbdc012177829026d04992cc106a1c815
sha256: "809a3797da7d49fad85f139555b352dd615f9d2da6ae9f1745c6978963491bae"
url: "https://pub.dev"
source: hosted
version: "1.1.5"
version: "1.1.7"
meta:
dependency: transitive
description:

View File

@ -79,26 +79,14 @@ dependencies:
flutter_smart_dialog: ^4.9.3+2
# 下滑关闭
dismissible_page: ^1.0.2
# 媒体播放
# flutter_meedu_media_kit:
# path: /Users/rr/Desktop/code/flutter_meedu_media_kit/package
# git:
# url: https://github.com/guozhigq/flutter_meedu_media_kit.git
# ref: feature-custom
# path: package
custom_sliding_segmented_control: ^1.7.5
# 加密
crypto: ^3.0.3
# 视频播放器
media_kit: ^1.1.4 # Primary package.
media_kit_video: ^1.1.5 # For video rendering.
media_kit_native_event_loop: ^1.0.7 # Support for higher number of concurrent instances & better performance.
media_kit_libs_android_video: ^1.3.2 # Android package for video native libraries.
media_kit_libs_ios_video: ^1.1.3 # iOS package for video native libraries.
media_kit_libs_macos_video: ^1.1.3 # macOS package for video native libraries.
media_kit_libs_windows_video: ^1.0.7 # Windows package for video native libraries.
media_kit_libs_linux: ^1.1.1
media_kit: ^1.1.6
media_kit_video: ^1.1.7
media_kit_libs_video: ^1.0.0
# 音量、亮度、屏幕控制
flutter_volume_controller: ^1.2.7