diff --git a/bytedesk_kefu/lib/ui/chat/page/chat_im_page.dart b/bytedesk_kefu/lib/ui/chat/page/chat_im_page.dart index 1084cdc..ac4f7a0 100755 --- a/bytedesk_kefu/lib/ui/chat/page/chat_im_page.dart +++ b/bytedesk_kefu/lib/ui/chat/page/chat_im_page.dart @@ -15,7 +15,7 @@ import 'package:bytedesk_kefu/util/bytedesk_events.dart'; import 'package:bytedesk_kefu/util/bytedesk_utils.dart'; import 'package:bytedesk_kefu/util/bytedesk_uuid.dart'; // import 'package:bytedesk_kefu/util/bytedesk_utils.dart'; -import 'package:file_picker/file_picker.dart'; +// import 'package:file_picker/file_picker.dart'; import 'package:sp_util/sp_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -751,42 +751,44 @@ class _ChatIMPageState extends State // 手机可以播放,但chrome无法播放 Future _pickVideo() async { try { - // final PickedFile videoFile = await _picker.getVideo( - // source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); - // BytedeskUtils.printLog('pick video path: ${videoFile.path}'); - // if (videoFile != null) { - // BlocProvider.of(context) - // ..add(UploadVideoEvent(filePath: videoFile.path)); - // } else { - // Fluttertoast.showToast(msg: '未选取视频'); - // } - // 使用file_picker替换image_picker - List? _paths = (await FilePicker.platform.pickFiles( - type: FileType.video, - allowMultiple: false, - allowedExtensions: [], - )) - ?.files; - if (_paths!.length > 0) { - // TODO: 将视频显示到对话消息中 - // TODO: 显示处理中loading - // 压缩 - // final info = await _flutterVideoCompress.compressVideo( - // _paths[0].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: ${_paths[0].path}, compress path: $afterPath'); - // // 上传 - // BlocProvider.of(context) - // ..add(UploadVideoEvent(filePath: afterPath)); - // 压缩后上传 + XFile? pickedFile = await _picker.pickVideo( + source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); + + if (pickedFile != null) { + BytedeskUtils.printLog('pick video path: ${pickedFile.path}'); + // BlocProvider.of(context) - ..add(UploadVideoEvent(filePath: _paths[0].path)); + ..add(UploadVideoEvent(filePath: pickedFile.path)); + } else { + Fluttertoast.showToast(msg: '未选取视频'); } + // 使用file_picker替换image_picker + // List? _paths = (await FilePicker.platform.pickFiles( + // type: FileType.video, + // allowMultiple: false, + // allowedExtensions: [], + // )) + // ?.files; + // if (_paths!.length > 0) { + // // TODO: 将视频显示到对话消息中 + // // TODO: 显示处理中loading + // // 压缩 + // // final info = await _flutterVideoCompress.compressVideo( + // // _paths[0].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: ${_paths[0].path}, compress path: $afterPath'); + // // // 上传 + // // BlocProvider.of(context) + // // ..add(UploadVideoEvent(filePath: afterPath)); + // // 压缩后上传 + // BlocProvider.of(context) + // ..add(UploadVideoEvent(filePath: _paths[0].path)); + // } } catch (e) { BytedeskUtils.printLog('pick video error ${e.toString()}'); Fluttertoast.showToast(msg: "未选取视频"); diff --git a/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart b/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart index df1b937..c034fb1 100755 --- a/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart +++ b/bytedesk_kefu/lib/ui/chat/page/chat_kf_page.dart @@ -15,7 +15,7 @@ import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; import 'package:bytedesk_kefu/util/bytedesk_events.dart'; import 'package:bytedesk_kefu/util/bytedesk_utils.dart'; import 'package:bytedesk_kefu/util/bytedesk_uuid.dart'; -import 'package:file_picker/file_picker.dart'; +// import 'package:file_picker/file_picker.dart'; import 'package:sp_util/sp_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -1343,42 +1343,44 @@ class _ChatKFPageState extends State // 手机可以播放,但chrome无法播放 Future _pickVideo() async { try { - // final PickedFile videoFile = await _picker.getVideo( - // source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); - // BytedeskUtils.printLog('pick video path: ${videoFile.path}'); - // if (videoFile != null) { - // BlocProvider.of(context) - // ..add(UploadVideoEvent(filePath: videoFile.path)); - // } else { - // Fluttertoast.showToast(msg: '未选取视频'); - // } - // 使用file_picker替换image_picker - List? _paths = (await FilePicker.platform.pickFiles( - type: FileType.video, - allowMultiple: false, - allowedExtensions: [], - )) - ?.files; - if (_paths!.length > 0) { - // TODO: 将视频显示到对话消息中 - // TODO: 显示处理中loading - // 压缩 - // final info = await _flutterVideoCompress.compressVideo( - // _paths[0].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: ${_paths[0].path}, compress path: $afterPath'); - // // 上传 - // BlocProvider.of(context) - // ..add(UploadVideoEvent(filePath: afterPath)); - // 压缩后上传 + XFile? pickedFile = await _picker.pickVideo( + source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); + + if (pickedFile != null) { + BytedeskUtils.printLog('pick video path: ${pickedFile.path}'); + // BlocProvider.of(context) - ..add(UploadVideoEvent(filePath: _paths[0].path)); + ..add(UploadVideoEvent(filePath: pickedFile.path)); + } else { + Fluttertoast.showToast(msg: '未选取视频'); } + // 使用file_picker替换image_picker + // List? _paths = (await FilePicker.platform.pickFiles( + // type: FileType.video, + // allowMultiple: false, + // allowedExtensions: [], + // )) + // ?.files; + // if (_paths!.length > 0) { + // // TODO: 将视频显示到对话消息中 + // // TODO: 显示处理中loading + // // 压缩 + // // final info = await _flutterVideoCompress.compressVideo( + // // _paths[0].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: ${_paths[0].path}, compress path: $afterPath'); + // // // 上传 + // // BlocProvider.of(context) + // // ..add(UploadVideoEvent(filePath: afterPath)); + // // 压缩后上传 + // BlocProvider.of(context) + // ..add(UploadVideoEvent(filePath: _paths[0].path)); + // } } catch (e) { BytedeskUtils.printLog('pick video error ${e.toString()}'); Fluttertoast.showToast(msg: "未选取视频"); diff --git a/bytedesk_kefu/lib/ui/chat/page/chat_ls_page.dart b/bytedesk_kefu/lib/ui/chat/page/chat_ls_page.dart index e59f0ba..525c8fd 100755 --- a/bytedesk_kefu/lib/ui/chat/page/chat_ls_page.dart +++ b/bytedesk_kefu/lib/ui/chat/page/chat_ls_page.dart @@ -12,7 +12,7 @@ import 'package:bytedesk_kefu/ui/widget/image_choose_widget.dart'; import 'package:bytedesk_kefu/util/bytedesk_constants.dart'; import 'package:bytedesk_kefu/util/bytedesk_events.dart'; // import 'package:bytedesk_kefu/util/bytedesk_utils.dart'; -import 'package:file_picker/file_picker.dart'; +// import 'package:file_picker/file_picker.dart'; import 'package:sp_util/sp_util.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -663,42 +663,44 @@ class _ChatLSPageState extends State // 手机可以播放,但chrome无法播放 Future _pickVideo() async { try { - // final PickedFile videoFile = await _picker.getVideo( - // source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); - // BytedeskUtils.printLog('pick video path: ${videoFile.path}'); - // if (videoFile != null) { - // BlocProvider.of(context) - // ..add(UploadVideoEvent(filePath: videoFile.path)); - // } else { - // Fluttertoast.showToast(msg: '未选取视频'); - // } - // 使用file_picker替换image_picker - List? _paths = (await FilePicker.platform.pickFiles( - type: FileType.video, - allowMultiple: false, - allowedExtensions: [], - )) - ?.files; - if (_paths!.length > 0) { - // TODO: 将视频显示到对话消息中 - // TODO: 显示处理中loading - // 压缩 - // final info = await _flutterVideoCompress.compressVideo( - // _paths[0].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: ${_paths[0].path}, compress path: $afterPath'); - // // 上传 - // BlocProvider.of(context) - // ..add(UploadVideoEvent(filePath: afterPath)); - // 压缩后上传 + XFile? pickedFile = await _picker.pickVideo( + source: ImageSource.gallery, maxDuration: const Duration(seconds: 10)); + + if (pickedFile != null) { + BytedeskUtils.printLog('pick video path: ${pickedFile.path}'); + // BlocProvider.of(context) - ..add(UploadVideoEvent(filePath: _paths[0].path)); + ..add(UploadVideoEvent(filePath: pickedFile.path)); + } else { + Fluttertoast.showToast(msg: '未选取视频'); } + // 使用file_picker替换image_picker + // List? _paths = (await FilePicker.platform.pickFiles( + // type: FileType.video, + // allowMultiple: false, + // allowedExtensions: [], + // )) + // ?.files; + // if (_paths!.length > 0) { + // // TODO: 将视频显示到对话消息中 + // // TODO: 显示处理中loading + // // 压缩 + // // final info = await _flutterVideoCompress.compressVideo( + // // _paths[0].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: ${_paths[0].path}, compress path: $afterPath'); + // // // 上传 + // // BlocProvider.of(context) + // // ..add(UploadVideoEvent(filePath: afterPath)); + // // 压缩后上传 + // BlocProvider.of(context) + // ..add(UploadVideoEvent(filePath: _paths[0].path)); + // } } catch (e) { BytedeskUtils.printLog('pick video error ${e.toString()}'); Fluttertoast.showToast(msg: "未选取视频"); diff --git a/bytedesk_kefu/pubspec.yaml b/bytedesk_kefu/pubspec.yaml index beac538..68ab91f 100644 --- a/bytedesk_kefu/pubspec.yaml +++ b/bytedesk_kefu/pubspec.yaml @@ -1,6 +1,6 @@ name: bytedesk_kefu description: the best app chat sdk in china, you can chat with the agent freely at anytime. the agent can chat with the visitor by web/pc/mac/ios/android client. -version: 1.4.4 +version: 1.4.5 homepage: https://www.weikefu.net environment: @@ -39,7 +39,7 @@ dependencies: # https://pub.dev/packages/image_picker image_picker: ^0.8.5 # image_picker在选择视频的时候有bug,选此替代 https://pub.dev/packages/file_picker - file_picker: ^4.5.1 + # file_picker: ^4.5.1 # https://pub.dev/packages/protobuf protobuf: ^2.0.1 # 下拉刷新 https://pub.dev/packages/flutter_easyrefresh