@ -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_constants.dart ' ;
import ' package:bytedesk_kefu/util/bytedesk_events.dart ' ;
import ' package:bytedesk_kefu/util/bytedesk_events.dart ' ;
/ / import ' package:bytedesk_kefu/util/bytedesk_utils.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:sp_util/sp_util.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:flutter_bloc/flutter_bloc.dart ' ;
import ' package:flutter_bloc/flutter_bloc.dart ' ;
@ -663,42 +663,44 @@ class _ChatLSPageState extends State<ChatLSPage>
/ / 手 机 可 以 播 放 , 但 chrome 无 法 播 放
/ / 手 机 可 以 播 放 , 但 chrome 无 法 播 放
Future < void > _pickVideo ( ) async {
Future < void > _pickVideo ( ) async {
try {
try {
/ / final PickedFile videoFile = await _picker . getVideo (
XFile ? pickedFile = await _picker . pickVideo (
/ / source : ImageSource . gallery , maxDuration: const Duration ( seconds: 10 ) ) ;
source : ImageSource . gallery , maxDuration: const Duration ( seconds: 10 ) ) ;
/ / BytedeskUtils . printLog ( ' pick video path: ${ videoFile . path } ' ) ;
/ / if ( videoFile ! = null ) {
if ( pickedFile ! = null ) {
/ / BlocProvider . of < MessageBloc > ( context )
BytedeskUtils . printLog ( ' pick video path: ${ pickedFile . path } ' ) ;
/ / . . add ( UploadVideoEvent ( filePath: videoFile . path ) ) ;
/ /
/ / } else {
/ / Fluttertoast . showToast ( msg: ' 未选取视频 ' ) ;
/ / }
/ / 使 用 file_picker 替 换 image_picker
List < PlatformFile > ? _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 < MessageBloc > ( context )
/ / . . add ( UploadVideoEvent ( filePath: afterPath ) ) ;
/ / 压 缩 后 上 传
BlocProvider . of < MessageBloc > ( context )
BlocProvider . of < MessageBloc > ( context )
. . add ( UploadVideoEvent ( filePath: _paths [ 0 ] . path ) ) ;
. . add ( UploadVideoEvent ( filePath: pickedFile . path ) ) ;
} else {
Fluttertoast . showToast ( msg: ' 未选取视频 ' ) ;
}
}
/ / 使 用 file_picker 替 换 image_picker
/ / List < PlatformFile > ? _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 < MessageBloc > ( context )
/ / / / . . add ( UploadVideoEvent ( filePath: afterPath ) ) ;
/ / / / 压 缩 后 上 传
/ / BlocProvider . of < MessageBloc > ( context )
/ / . . add ( UploadVideoEvent ( filePath: _paths [ 0 ] . path ) ) ;
/ / }
} catch ( e ) {
} catch ( e ) {
BytedeskUtils . printLog ( ' pick video error ${ e . toString ( ) } ' ) ;
BytedeskUtils . printLog ( ' pick video error ${ e . toString ( ) } ' ) ;
Fluttertoast . showToast ( msg: " 未选取视频 " ) ;
Fluttertoast . showToast ( msg: " 未选取视频 " ) ;