|
|
@ -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,6 +1617,70 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
// 录制视频
|
|
|
|
// 录制视频
|
|
|
|
Future<void> _captureVideo() async {
|
|
|
|
Future<void> _captureVideo() async {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
XFile? pickedFile = await _picker.pickVideo(
|
|
|
|
XFile? pickedFile = await _picker.pickVideo(
|
|
|
|
source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
|
|
|
|
source: ImageSource.camera, maxDuration: const Duration(seconds: 10));
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -1642,6 +1707,7 @@ class _ChatKFPageState extends State<ChatKFPage>
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Fluttertoast.showToast(msg: '未录制视频');
|
|
|
|
Fluttertoast.showToast(msg: '未录制视频');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
BytedeskUtils.printLog('take video error ${e.toString()}');
|
|
|
|
BytedeskUtils.printLog('take video error ${e.toString()}');
|
|
|
|
Fluttertoast.showToast(msg: "未录制视频");
|
|
|
|
Fluttertoast.showToast(msg: "未录制视频");
|
|
|
|