main
王亚玲 11 months ago
parent 1f008cfaec
commit 5f5579dc5a

@ -1301,7 +1301,7 @@ class _ChatKFPageState extends State<ChatKFPage>
deleteListener: () async { deleteListener: () async {
Alert.dismiss(context); Alert.dismiss(context);
bool canUseCamera = await PermissionTool.haveCameraPermission(); bool canUseCamera = await PermissionTool.havePhotoPermission();
if (!canUseCamera) { if (!canUseCamera) {
PermissionTool.showOpenPermissionDialog( PermissionTool.showOpenPermissionDialog(
context, "没有相册使用权限,授予相册使用权限后才能上传素材"); context, "没有相册使用权限,授予相册使用权限后才能上传素材");
@ -1540,18 +1540,19 @@ class _ChatKFPageState extends State<ChatKFPage>
// chrome // chrome
Future<void> _pickVideo() async { Future<void> _pickVideo() async {
try { try {
bool permission = await Permission.camera.isGranted; bool permission = await Permission.camera.isGranted;
if (!permission) { if (!permission) {
Alert.show( Alert.show(
context, context,
NormalContentDialog( NormalContentDialog(
title: '需要获取相访问权限', title: '需要获取相访问权限',
content: Row( content: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
//Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,), //Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,),
Text( Text(
'允许访问相机上传图片', '允许访问相册上传视频',
style: TextStyle(color: Color(0xFF666666), fontSize: 14), style: TextStyle(color: Color(0xFF666666), fontSize: 14),
), ),
], ],
@ -1564,10 +1565,10 @@ class _ChatKFPageState extends State<ChatKFPage>
deleteListener: () async { deleteListener: () async {
Alert.dismiss(context); Alert.dismiss(context);
bool canUseCamera = await PermissionTool.haveCameraPermission(); bool canUseCamera = await PermissionTool.havePhotoPermission();
if (!canUseCamera) { if (!canUseCamera) {
PermissionTool.showOpenPermissionDialog( PermissionTool.showOpenPermissionDialog(
context, "没有相机使用权限,授予相机使用权限后才能上传素材"); context, "没有相册使用权限,授予相册使用权限后才能上传素材");
} else{ } else{
XFile? pickedFile = await _picker.pickVideo( XFile? pickedFile = await _picker.pickVideo(
@ -1616,31 +1617,96 @@ class _ChatKFPageState extends State<ChatKFPage>
// //
Future<void> _captureVideo() async { Future<void> _captureVideo() async {
try { try {
XFile? pickedFile = await _picker.pickVideo(
source: ImageSource.camera, maxDuration: const Duration(seconds: 10)); bool permission = await Permission.camera.isGranted;
// if (!permission) {
if (pickedFile != null) {
BytedeskUtils.printLog('take video path: ${pickedFile.path}'); Alert.show(
// TODO: context,
// TODO: loading NormalContentDialog(
// title: '需要获取相机访问权限',
// final info = await _flutterVideoCompress.compressVideo( content: Row(
// pickedFile.path, mainAxisAlignment: MainAxisAlignment.center,
// quality: children: [
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality) //Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,),
// deleteOrigin: false, // default(false) Text(
// ); '允许访问相机上传图片',
// // debugBytedeskUtils.printLog(info.toJson().toString()); style: TextStyle(color: Color(0xFF666666), fontSize: 14),
// String? afterPath = info.toJson()['path']; ),
// // BytedeskUtils.printLog('video path: ${pickedFile.path}, compress path: $afterPath'); ],
// // ),
// BlocProvider.of<MessageBloc>(context) items: ["残忍拒绝"],
// ..add(UploadVideoEvent(filePath: afterPath)); listener: (index) {
// Alert.dismiss(context);
BlocProvider.of<MessageBloc>(context) },
..add(UploadVideoEvent(filePath: pickedFile.path)); deleteItem: "立即授权",
deleteListener: () async {
Alert.dismiss(context);
bool canUseCamera = await PermissionTool.haveCameraPermission();
if (!canUseCamera) {
PermissionTool.showOpenPermissionDialog(
context, "没有相机使用权限,授予相机使用权限后才能上传素材");
} else{
XFile? pickedFile = await _picker.pickVideo(
source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
//
if (pickedFile != null) {
BytedeskUtils.printLog('take video path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
// final info = await _flutterVideoCompress.compressVideo(
// pickedFile.path,
// quality:
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // BytedeskUtils.printLog('video path: ${pickedFile.path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
//
BlocProvider.of<MessageBloc>(context)
..add(UploadVideoEvent(filePath: pickedFile.path));
} else {
Fluttertoast.showToast(msg: '未录制视频');
}
}
},
type: NormalTextDialogType.delete,
),
);
} else { } else {
Fluttertoast.showToast(msg: '未录制视频'); XFile? pickedFile = await _picker.pickVideo(
source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
//
if (pickedFile != null) {
BytedeskUtils.printLog('take video path: ${pickedFile.path}');
// TODO:
// TODO: loading
//
// final info = await _flutterVideoCompress.compressVideo(
// pickedFile.path,
// quality:
// VideoQuality.LowQuality, // default(VideoQuality.DefaultQuality)
// deleteOrigin: false, // default(false)
// );
// // debugBytedeskUtils.printLog(info.toJson().toString());
// String? afterPath = info.toJson()['path'];
// // BytedeskUtils.printLog('video path: ${pickedFile.path}, compress path: $afterPath');
// //
// BlocProvider.of<MessageBloc>(context)
// ..add(UploadVideoEvent(filePath: afterPath));
//
BlocProvider.of<MessageBloc>(context)
..add(UploadVideoEvent(filePath: pickedFile.path));
} else {
Fluttertoast.showToast(msg: '未录制视频');
}
} }
} catch (e) { } catch (e) {
BytedeskUtils.printLog('take video error ${e.toString()}'); BytedeskUtils.printLog('take video error ${e.toString()}');

Loading…
Cancel
Save