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

@ -1301,7 +1301,7 @@ class _ChatKFPageState extends State<ChatKFPage>
deleteListener: () async {
Alert.dismiss(context);
bool canUseCamera = await PermissionTool.haveCameraPermission();
bool canUseCamera = await PermissionTool.havePhotoPermission();
if (!canUseCamera) {
PermissionTool.showOpenPermissionDialog(
context, "没有相册使用权限,授予相册使用权限后才能上传素材");
@ -1540,18 +1540,19 @@ class _ChatKFPageState extends State<ChatKFPage>
// chrome
Future<void> _pickVideo() async {
try {
bool permission = await Permission.camera.isGranted;
if (!permission) {
Alert.show(
context,
NormalContentDialog(
title: '需要获取相访问权限',
title: '需要获取相访问权限',
content: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
//Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,),
Text(
'允许访问相机上传图片',
'允许访问相册上传视频',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
],
@ -1564,10 +1565,10 @@ class _ChatKFPageState extends State<ChatKFPage>
deleteListener: () async {
Alert.dismiss(context);
bool canUseCamera = await PermissionTool.haveCameraPermission();
bool canUseCamera = await PermissionTool.havePhotoPermission();
if (!canUseCamera) {
PermissionTool.showOpenPermissionDialog(
context, "没有相机使用权限,授予相机使用权限后才能上传素材");
context, "没有相册使用权限,授予相册使用权限后才能上传素材");
} else{
XFile? pickedFile = await _picker.pickVideo(
@ -1616,31 +1617,96 @@ class _ChatKFPageState extends State<ChatKFPage>
//
Future<void> _captureVideo() async {
try {
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));
bool permission = await Permission.camera.isGranted;
if (!permission) {
Alert.show(
context,
NormalContentDialog(
title: '需要获取相机访问权限',
content: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
//Image.asset(R.ASSETS_LOCATION_PER_PNG,width: 44.rw,height: 44.rw,),
Text(
'允许访问相机上传图片',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
],
),
items: ["残忍拒绝"],
listener: (index) {
Alert.dismiss(context);
},
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 {
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) {
BytedeskUtils.printLog('take video error ${e.toString()}');

Loading…
Cancel
Save