opt: 全屏方式优化
This commit is contained in:
@ -5,6 +5,8 @@ PODS:
|
|||||||
- device_info_plus (0.0.1):
|
- device_info_plus (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- Flutter (1.0.0)
|
- Flutter (1.0.0)
|
||||||
|
- flutter_volume_controller (0.0.1):
|
||||||
|
- Flutter
|
||||||
- FMDB (2.7.5):
|
- FMDB (2.7.5):
|
||||||
- FMDB/standard (= 2.7.5)
|
- FMDB/standard (= 2.7.5)
|
||||||
- FMDB/standard (2.7.5)
|
- FMDB/standard (2.7.5)
|
||||||
@ -46,6 +48,7 @@ DEPENDENCIES:
|
|||||||
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
|
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
|
||||||
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
|
- flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`)
|
||||||
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
|
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
|
||||||
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
|
- media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`)
|
||||||
- media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`)
|
- media_kit_native_event_loop (from `.symlinks/plugins/media_kit_native_event_loop/ios`)
|
||||||
@ -74,6 +77,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/device_info_plus/ios"
|
:path: ".symlinks/plugins/device_info_plus/ios"
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: Flutter
|
:path: Flutter
|
||||||
|
flutter_volume_controller:
|
||||||
|
:path: ".symlinks/plugins/flutter_volume_controller/ios"
|
||||||
image_gallery_saver:
|
image_gallery_saver:
|
||||||
:path: ".symlinks/plugins/image_gallery_saver/ios"
|
:path: ".symlinks/plugins/image_gallery_saver/ios"
|
||||||
media_kit_libs_ios_video:
|
media_kit_libs_ios_video:
|
||||||
@ -109,6 +114,7 @@ SPEC CHECKSUMS:
|
|||||||
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
|
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
|
||||||
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
|
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
|
||||||
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
|
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
|
||||||
|
flutter_volume_controller: e4d5832f08008180f76e30faf671ffd5a425e529
|
||||||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
|
||||||
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
|
image_gallery_saver: cb43cc43141711190510e92c460eb1655cd343cb
|
||||||
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
|
media_kit_libs_ios_video: a5fe24bc7875ccd6378a0978c13185e1344651c1
|
||||||
|
|||||||
@ -1,14 +1,34 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:auto_orientation/auto_orientation.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
//横屏
|
//横屏
|
||||||
/// 低版本xcode不支持auto_orientation
|
|
||||||
Future<void> landScape() async {
|
Future<void> landScape() async {
|
||||||
if (Platform.isAndroid || Platform.isIOS) {
|
dynamic document;
|
||||||
await AutoOrientation.landscapeAutoMode(forceSensor: true);
|
try {
|
||||||
|
if (kIsWeb) {
|
||||||
|
await document.documentElement?.requestFullscreen();
|
||||||
|
} else if (Platform.isAndroid || Platform.isIOS) {
|
||||||
|
await SystemChrome.setEnabledSystemUIMode(
|
||||||
|
SystemUiMode.immersiveSticky,
|
||||||
|
overlays: [],
|
||||||
|
);
|
||||||
|
await SystemChrome.setPreferredOrientations(
|
||||||
|
[
|
||||||
|
DeviceOrientation.landscapeLeft,
|
||||||
|
DeviceOrientation.landscapeRight,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
} else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
|
||||||
|
await const MethodChannel('com.alexmercerind/media_kit_video')
|
||||||
|
.invokeMethod(
|
||||||
|
'Utils.EnterNativeFullscreen',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (exception, stacktrace) {
|
||||||
|
debugPrint(exception.toString());
|
||||||
|
debugPrint(stacktrace.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,14 +47,24 @@ Future<void> enterFullScreen() async {
|
|||||||
|
|
||||||
//退出全屏显示
|
//退出全屏显示
|
||||||
Future<void> exitFullScreen() async {
|
Future<void> exitFullScreen() async {
|
||||||
late SystemUiMode mode;
|
dynamic document;
|
||||||
if ((Platform.isAndroid &&
|
try {
|
||||||
(await DeviceInfoPlugin().androidInfo).version.sdkInt >= 29) ||
|
if (kIsWeb) {
|
||||||
!Platform.isAndroid) {
|
document.exitFullscreen();
|
||||||
mode = SystemUiMode.edgeToEdge;
|
} else if (Platform.isAndroid || Platform.isIOS) {
|
||||||
} else {
|
await SystemChrome.setEnabledSystemUIMode(
|
||||||
mode = SystemUiMode.manual;
|
SystemUiMode.manual,
|
||||||
|
overlays: SystemUiOverlay.values,
|
||||||
|
);
|
||||||
|
await SystemChrome.setPreferredOrientations([]);
|
||||||
|
} else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) {
|
||||||
|
await const MethodChannel('com.alexmercerind/media_kit_video')
|
||||||
|
.invokeMethod(
|
||||||
|
'Utils.ExitNativeFullscreen',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (exception, stacktrace) {
|
||||||
|
debugPrint(exception.toString());
|
||||||
|
debugPrint(stacktrace.toString());
|
||||||
}
|
}
|
||||||
await SystemChrome.setEnabledSystemUIMode(mode,
|
|
||||||
overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -178,7 +178,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
/// 进入全屏
|
/// 进入全屏
|
||||||
await enterFullScreen();
|
await enterFullScreen();
|
||||||
// 横屏
|
// 横屏
|
||||||
await landScape();
|
await verticalScreen();
|
||||||
break;
|
break;
|
||||||
case FullScreenMode.horizontal:
|
case FullScreenMode.horizontal:
|
||||||
|
|
||||||
|
|||||||
12
pubspec.lock
12
pubspec.lock
@ -57,14 +57,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
auto_orientation:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: auto_orientation
|
|
||||||
sha256: cd56bb59b36fa54cc28ee254bc600524f022a4862f31d5ab20abd7bb1c54e678
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.3.1"
|
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -309,10 +301,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: dio
|
name: dio
|
||||||
sha256: "3866d67f93523161b643187af65f5ac08bc991a5bcdaf41a2d587fe4ccb49993"
|
sha256: ce75a1b40947fea0a0e16ce73337122a86762e38b982e1ccb909daa3b9bc4197
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.3.0"
|
version: "5.3.2"
|
||||||
dio_cookie_manager:
|
dio_cookie_manager:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -108,7 +108,6 @@ dependencies:
|
|||||||
# 进度条
|
# 进度条
|
||||||
audio_video_progress_bar: ^1.0.1
|
audio_video_progress_bar: ^1.0.1
|
||||||
animations: ^2.0.7
|
animations: ^2.0.7
|
||||||
auto_orientation: ^2.3.1
|
|
||||||
|
|
||||||
# 获取appx信息
|
# 获取appx信息
|
||||||
package_info_plus: ^4.1.0
|
package_info_plus: ^4.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user