jyj 4 年之前
父节点
当前提交
dc2e3a0a6c

+ 25 - 12
lib/internal/bbs/page/interrogation_page.dart

@@ -50,6 +50,7 @@ class InterrogationPageState extends State<InterrogationPage> {
   double percent = 0.0;
   String addressName = "";
   VideoPlayerController _controller;
+  VideoPlayerController _controllerFile;
   @override
   void initState() {
     super.initState();
@@ -138,18 +139,30 @@ class InterrogationPageState extends State<InterrogationPage> {
     print(key);
     print(333);
     try {
-      var _imageFile = await ImagePicker.pickVideo(
-          source: key == 1 ? ImageSource.camera : ImageSource.gallery,
-      );
-      if (_imageFile != null) {
-        // print(123);
-        // print(_imageFile);
-        // print(jsonEncode(_imageFile));
-        print(123);
-        _uploadImage(_imageFile.path);
-        // upLoadFileOnceVideo(_imageFile.path);
-        setState(() {});
-      }
+      await ImagePicker.pickVideo(
+        source: key == 1 ? ImageSource.camera : ImageSource.gallery,
+      )
+      .then((File f) async{
+        if (f != null) {
+        _controllerFile = VideoPlayerController.file(f);
+        _controllerFile.initialize().then((val){
+          _controllerFile.setLooping(true);
+          int seconds = _controllerFile.value.duration.inSeconds;
+          print("视频时长:$seconds");
+          int fileSize=f.lengthSync();//单位B
+          print("视频大小:${fileSize}");
+          print("视频大小:${f.path}");
+          if (seconds <= 300) {
+            _uploadImage(f.path);
+            // upLoadFileOnce(_imageFile.path);
+            // setState(() {});
+          }else {
+            toasts("视频时长不能大于5分钟!");
+          }
+        });}
+      })
+      ;
+      
     } catch (e) {
       toasts("没有权限,无法打开相册!");
     }

+ 0 - 580
lib/internal/bbs/page/tab/video/video_upload copy.dart

@@ -1,580 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:liftmanager/res/gaps.dart';
-import 'package:liftmanager/net/api_service.dart';
-import 'package:liftmanager/utils/toast.dart';
-import 'package:liftmanager/widgets/app_bar.dart';
-import 'package:liftmanager/internal/search/search_router.dart';
-import 'package:liftmanager/widgets/app_search_bar.dart';
-import 'package:liftmanager/res/resources.dart';
-import 'package:liftmanager/routers/fluro_navigator.dart';
-import 'package:liftmanager/widgets/load_image.dart';
-import 'package:liftmanager/widgets/selected_image_change.dart';
-import 'package:image_picker/image_picker.dart';
-import 'dart:io';
-import 'package:liftmanager/widgets/bbs_content.dart';
-import 'package:flutter_screenutil/flutter_screenutil.dart';
-import 'package:flutter_spinkit/flutter_spinkit.dart';
-import 'package:video_player/video_player.dart';
-import 'package:liftmanager/utils/image_utils.dart';
-import 'package:liftmanager/internal/bbs/bbs_router.dart';
-import 'package:flustars/flustars.dart' as FlutterStars;
-import 'package:liftmanager/common/common.dart';
-import 'package:liftmanager/utils/theme_utils.dart';
-
-class VideoUpload extends StatefulWidget {
-  // BrandPage(this.id);
-
-  // final String id;
-
-  @override
-  State<StatefulWidget> createState() {
-    return VideoUploadState();
-  }
-}
-
-class VideoUploadState extends State<VideoUpload> {
-  // NewsDetailItem item = NewsDetailItem();
-
-  ScrollController _scrollController = new ScrollController();
-  String brandChiose = '请选择';
-  String brandName = "品牌";
-  int brandIdss;
-  bool sortBool = true;
-  List<String> imagesUrl = [];
-  List<String> videoUrl = [];
-  @override
-  void initState() {
-    super.initState();
-  }
-
-  upLoadFileOnce(path) {
-    showLoading(context, "正在上传...");
-    NewApiService().upload(path, onSuccess: (res) {
-      // imagesUrl.add(res.path);
-      dismissLoading(context);
-
-      setState(() {
-        videoUrl = [];
-        imagesUrl = [];
-        videoUrl.add(res.pathUrl);
-        imagesUrl.add(res.coverUrl);
-      });
-    }, onError: (code, msg) {
-      dismissLoading(context);
-      toasts(msg);
-    });
-  }
-
-  List<dynamic> brandList;
-  Future getBrandList() async {
-    await NewApiService().getBrandListNoPage(onSuccess: (res) {
-      if (res != null) {
-        brandList = res;
-        setState(() {});
-      }
-    }, onError: (code, msg) {
-      toasts(msg);
-    });
-  }
-
-  ///选择视频
-  void selectPicker() {
-    showDialog(
-        context: context,
-        builder: (BuildContext context) {
-          return SimpleDialog(
-              title: Text("选择方式"),
-              children: ["拍照", '从手机相册选择'].map((String value) {
-                print("$value");
-                return SimpleDialogOption(
-                  child: Text(
-                    "${value}",
-                    style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
-                  ),
-                  onPressed: () {
-                    _getImage(value == '拍照' ? 1 : 0);
-                    Navigator.of(context).pop();
-                  },
-                );
-              }).toList());
-        });
-  }
-
-  void _getImage(int key) async {
-    print(key);
-    print(333);
-    try {
-      var _imageFile = await ImagePicker.pickVideo(
-        source: key == 1 ? ImageSource.camera : ImageSource.gallery,
-      );
-      if (_imageFile != null) {
-        upLoadFileOnce(_imageFile.path);
-        setState(() {});
-      }
-    } catch (e) {
-      toasts("没有权限,无法打开相册!");
-    }
-  }
-
-  // 焦点控制
-  FocusNode focusNode1 = new FocusNode();
-  GlobalKey _formKey = new GlobalKey<FormState>();
-  TextEditingController _titleController = new TextEditingController();
-  TextEditingController _descController = new TextEditingController();
-  
-
-  @override
-  Widget build(BuildContext context) {
-    double width = MediaQuery.of(context).size.width;
-    double height = MediaQuery.of(context).size.height;
-
-    return Scaffold(
-      resizeToAvoidBottomPadding: false, //不让键盘弹上去
-      appBar: MyAppBar(
-        centerTitle: "上传视频",
-      ),
-      body: GestureDetector(
-        onTap: () {
-          // 点击空白页面关闭键盘
-          FocusScope.of(context).requestFocus(focusNode1);
-        },
-        child: Stack(
-          children: <Widget>[
-            Container(
-                child: ListView(children: <Widget>[
-              Form(
-                key: _formKey, //设置globalKey,用于后面获取FormState
-                // autovalidate: true, //开启自动校验
-                child: Column(
-                  children: <Widget>[
-                    ChioseThisRight(
-                        label: "电梯品牌",
-                        value: brandChiose,
-                        fun: () {
-                          setState(() {
-                            // brandChiose = brandListChiose[index];
-                            sortBool = false;
-                            print(5656333);
-                          });
-                          getBrandList();
-                          // Navigator.maybePop(context);
-                        }),
-                    Row(
-                      crossAxisAlignment: CrossAxisAlignment.start,
-                      mainAxisAlignment: MainAxisAlignment.start,
-                      children: <Widget>[
-                        Container(
-                          padding: EdgeInsets.only(
-                              left: ScreenUtil().setWidth(15),
-                              top: ScreenUtil().setWidth(10),
-                              bottom: ScreenUtil().setWidth(5)),
-                          child: Text(
-                            "视频标题",
-                            style: TextStyle(
-                              // fontSize:ScreenUtil().setSp(14),
-                            ),
-                            textAlign: TextAlign.left,
-                          ),
-                        ),
-                      ],
-                    ),
-                    Container(
-                      height: 80,
-                      padding: EdgeInsets.only(
-                          left: ScreenUtil().setWidth(15),
-                          right: ScreenUtil().setWidth(15),
-                          bottom: ScreenUtil().setWidth(20)),
-                      child: TextFormField(
-                          // autofocus: true,
-                          maxLength: 50,
-                          cursorColor: Color(0xffcccccc),
-                          controller: _titleController,
-                          maxLines: 5,
-                          decoration: InputDecoration(
-                            contentPadding: EdgeInsets.all(0),
-
-                            hintText: '请输入你上传视频的标题',
-                            hintStyle: TextStyle(color: Color(0xffcccccc)),
-                            focusedBorder: InputBorder.none,
-                            border: InputBorder.none,
-                            // filled: true, // 背景色
-                            // fillColor: Colors.cyan.withAlpha(35),
-                            // icon: Icon(Icons.person)
-                          ),
-
-                          // 校验
-                          validator: (val) {
-                            return val.trim().length > 0 ? null : "不能为空";
-                          }),
-                    ),
-                    SizedBox(
-                      height: 6,
-                      child: Container(color: ThemeUtils.getDialogTextFieldColor(context)),
-                    ),
-                    Row(
-                      crossAxisAlignment: CrossAxisAlignment.start,
-                      mainAxisAlignment: MainAxisAlignment.start,
-                      children: <Widget>[
-                        Container(
-                          padding: EdgeInsets.only(
-                              left: ScreenUtil().setWidth(15),
-                              top: ScreenUtil().setWidth(10),
-                              bottom: ScreenUtil().setWidth(5)),
-                          child: Text(
-                            "视频简介",
-                            style: TextStyle(
-                              // fontSize:ScreenUtil().setSp(14),
-                            ),
-                            textAlign: TextAlign.left,
-                          ),
-                        ),
-                      ],
-                    ),
-                    Container(
-                      height: 120,
-                      padding: EdgeInsets.only(
-                          left: ScreenUtil().setWidth(15),
-                          right: ScreenUtil().setWidth(15),
-                          bottom: ScreenUtil().setWidth(20)),
-                      child: TextFormField(
-                          // autofocus: true,
-                          maxLength: 500,
-                          cursorColor: Color(0xffcccccc),
-                          controller: _descController,
-                          maxLines: 5,
-                          decoration: InputDecoration(
-                            contentPadding: EdgeInsets.all(0),
-
-                            hintText: '请输入您上传视频的简介',
-                            hintStyle: TextStyle(color: Color(0xffcccccc)),
-                            focusedBorder: InputBorder.none,
-                            border: InputBorder.none,
-                            // filled: true, // 背景色
-                            // fillColor: Colors.cyan.withAlpha(35),
-                            // icon: Icon(Icons.person)
-                          ),
-
-                          // 校验
-                          validator: (val) {
-                            return val.trim().length > 0 ? null : "不能为空";
-                          }),
-                    ),
-                    SizedBox(
-                      height: 6,
-                      child: Container(color: ThemeUtils.getDialogTextFieldColor(context)),
-                    ),
-                    Container(
-                width: width,
-                padding: EdgeInsets.only(left:15,top:15),
-                child: Text(
-                                                        "(建议时长3分钟,建议大小50M)",
-                                                        style: TextStyle(
-                                                          color: Colors.red,
-                                                            fontSize:
-                                                                ScreenUtil()
-                                                                    .setSp(14),
-                                                            ),
-                                                            textAlign: TextAlign.left,
-                                                      ),
-              ),
-                    Container(
-                        color: ThemeUtils.getTabsBg(context),
-                        child: GridView.builder(
-                          shrinkWrap: true,
-                          padding:
-                              const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
-                          physics: NeverScrollableScrollPhysics(),
-                          gridDelegate:
-                              SliverGridDelegateWithFixedCrossAxisCount(
-                                  crossAxisCount: 3, childAspectRatio: 1.18),
-                          itemCount:
-                              videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
-                          itemBuilder: (_, index) {
-                            return Stack(
-                              children: <Widget>[
-                                Center(
-                                  child: SelectedImage(
-                                      image: index < videoUrl.length
-                                          ? imagesUrl[index]
-                                          : null,
-                                      // image: index < videoUrl.length ? videoUrl[index] : null,
-                                      index: index,
-                                      onTap: () {
-                                        if (index >= videoUrl.length) {
-                                          selectPicker();
-                                        }
-                                        FocusScope.of(context)
-                                            .requestFocus(FocusNode());
-                                        print(index);
-                                        print(videoUrl);
-                                      }),
-                                ),
-                                index < videoUrl.length
-                                    ? Positioned(
-                                        top: 0,
-                                        right: 0,
-                                        child: GestureDetector(
-                                          onTap: () {
-                                            print(index);
-                                            videoUrl.remove(videoUrl[index]);
-                                            imagesUrl.remove(imagesUrl[index]);
-                                            setState(() {});
-                                          },
-                                          child: Icon(
-                                            IconData(0xe62a,
-                                                fontFamily: "myfont"),
-                                            size: 24.0,
-                                            color: Color(0xff999999),
-                                          ),
-                                        ))
-                                    : Container(
-                                        child: null,
-                                      )
-                              ],
-                            );
-                          },
-                        )),
-                    SizedBox(
-                      height: ScreenUtil().setWidth(80),
-                    ),
-                  ],
-                ),
-              )
-            ])),
-            Positioned(
-                bottom: 0,
-                left: 0,
-                child: Container(
-                  width: width,
-                  padding: EdgeInsets.only(
-                      top: ScreenUtil().setWidth(15),
-                      bottom: ScreenUtil().setWidth(15),
-                      left: ScreenUtil().setWidth(25),
-                      right: ScreenUtil().setWidth(25)),
-                  color: ThemeUtils.getDialogTextFieldColor(context),
-                  child: Container(
-                    height: ScreenUtil().setWidth(44),
-                    decoration: BoxDecoration(
-                      borderRadius:
-                          BorderRadius.circular(ScreenUtil().setWidth(22)),
-                      gradient: const LinearGradient(
-                          colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
-                    ),
-                    child: FlatButton(
-                      // padding: EdgeInsets.all(15.0),
-                      child: Text("提交"),
-                      textColor: Colors.white,
-                      onPressed: () {
-                        if (brandIdss == null) {
-                          toasts("请选择品牌");
-                          return;
-                        }
-                        if (videoUrl.length < 1) {
-                          toasts("请上传视频");
-                          return;
-                        }
-                        String videos = videoUrl.join(",");
-                        String images = imagesUrl.join(",");
-                        if ((_formKey.currentState as FormState).validate()) {
-                          dynamic obj = {
-                            "brandId": brandIdss,
-                            "title": _titleController.text,
-                            "descr": _descController.text,
-                            "url": videos,
-                            "cover": images,
-                            "checkFlag": 2,
-                            "statuz": 1,
-                            "platformFlag": 1,
-                            "userId":FlutterStars.SpUtil.getString(Constant.userId),
-                          };
-                          showLoading(context, "正在提交...");
-
-                          NewApiService().addVideo(obj, onSuccess: (res) {
-                            dismissLoading(context);
-                            toasts("提交成功");
-
-                            Navigator.pop(context);
-                          }, onError: (code, msg) {
-                            dismissLoading(context);
-                            toasts(msg);
-                          });
-                        }
-                      },
-                    ),
-                  ),
-                )),
-            !sortBool
-                ? Positioned(
-                    top: 0,
-                    left: 0,
-                    child: Container(
-                        width: width,
-                        height: height,
-                        color: Color.fromRGBO(0, 0, 0, 0.5)))
-                : Container(child: null),
-            !sortBool
-                ? Positioned(
-                    top: 0,
-                    right: 0,
-                    child: Container(
-                        width: width / 4 * 3,
-                        height: height,
-                        color: Colors.white,
-                        padding: EdgeInsets.all(10),
-                        child: ListView(
-                          children: <Widget>[
-                            Container(
-                              padding:
-                                  EdgeInsets.only(left: 5, top: 5, bottom: 10),
-                              child: Text(
-                                "品牌",
-                                style: TextStyle(
-                                    color: Color(0xff666666),
-                                    fontSize: ScreenUtil().setSp(16)),
-                                textAlign: TextAlign.start,
-                              ),
-                            ),
-                            brandList != null && brandList != []
-                                ? Container(
-                                    child: Wrap(
-                                    alignment: WrapAlignment.start,
-                                    crossAxisAlignment:
-                                        WrapCrossAlignment.center,
-                                    children:
-                                        brandList.asMap().keys.map((index) {
-                                      return InkWell(
-                                        onTap: () {
-                                          print("666");
-
-                                          setState(() {
-                                            sortBool = true;
-                                            brandChiose =
-                                                brandList[index].name ?? "";
-                                            brandIdss = brandList[index].id;
-                                          });
-                                        },
-                                        child: Container(
-                                          width: width / 4 - 17,
-                                          padding: EdgeInsets.only(
-                                              bottom: ScreenUtil().setWidth(10),
-                                              top: ScreenUtil().setWidth(10)),
-                                          margin: EdgeInsets.only(
-                                              left: 5,
-                                              right: 5,
-                                              bottom: 5,
-                                              top: 5),
-                                          decoration: BoxDecoration(
-                                              // border: Border(
-                                              //   bottom: BorderSide(width: 0.5, color: Colours.line),
-                                              // ),
-                                              color: Color(0xfff5f5f5)),
-                                          child: Text(
-                                            brandList[index].name ?? "",
-                                            style: TextStyle(
-                                                color: Color(0xff666666),
-                                                fontSize:
-                                                    ScreenUtil().setSp(15)),
-                                            textAlign: TextAlign.center,
-                                          ),
-                                        ),
-                                      );
-                                    }).toList(),
-                                  ))
-                                : loadCircle()
-                          ],
-                        )))
-                : Container(child: null),
-          ],
-        ),
-      ),
-    );
-  }
-
-  Widget loadCircle() {
-    return Container(
-      padding: EdgeInsets.only(top: 10, bottom: 10),
-      color: ThemeUtils.getTabsBg(context),
-      child: Center(
-        child: SpinKitFadingCircle(
-          color: Colors.blueAccent,
-          size: 30.0,
-        ),
-      ),
-    );
-  }
-}
-
-class ChioseThisRight extends StatelessWidget {
-  ChioseThisRight(
-      {Key key, this.value, this.label, this.fun, this.labelText = '请选择'})
-      : super(key: key);
-  String value;
-  String label;
-  Function fun;
-  String labelText;
-  @override
-  Widget build(BuildContext context) {
-    double width = MediaQuery.of(context).size.width;
-    return InkWell(
-      onTap: () {
-        fun();
-      },
-      child: Container(
-        padding: EdgeInsets.only(
-            top: ScreenUtil().setWidth(15), bottom: ScreenUtil().setWidth(15)),
-        margin: EdgeInsets.only(left: ScreenUtil().setWidth(15)),
-        decoration: BoxDecoration(
-          border: Border(
-            bottom: BorderSide(width: 0.5, color: Colours.line),
-          ),
-        ),
-        child: Row(
-            mainAxisAlignment: MainAxisAlignment.spaceBetween,
-            children: <Widget>[
-              Text(
-                label,
-                style: TextStyle(
-                  // fontSize: ScreenUtil().setSp(14)
-                ),
-                textAlign: TextAlign.start,
-              ),
-              value.isEmpty
-                  ? Container(
-                      child: Row(children: <Widget>[
-                        Text(
-                          labelText,
-                          style: TextStyle(
-                            color: Color(0xffcccccc),
-                            // fontSize: ScreenUtil().setSp(14)
-                          ),
-                          textAlign: TextAlign.start,
-                        ),
-                        Container(
-                          padding: EdgeInsets.only(top: 3),
-                          child: Icon(
-                            Icons.keyboard_arrow_right,
-                            size: 20.0,
-                            color: Color(0xffcccccc),
-                          ),
-                        ),
-                        SizedBox(width: 10)
-                      ]),
-                    )
-                  : Container(
-                      padding:
-                          EdgeInsets.only(right: ScreenUtil().setWidth(15)),
-                      child: Row(children: <Widget>[
-                        Text(
-                          value,
-                          style: TextStyle(
-                              color: Color(0xff222222),
-                              fontSize: ScreenUtil().setSp(14)),
-                          textAlign: TextAlign.start,
-                        ),
-                      ]),
-                    ),
-            ]),
-      ),
-    );
-  }
-}

+ 24 - 7
lib/internal/bbs/page/tab/video/video_upload.dart

@@ -48,6 +48,7 @@ class VideoUploadState extends State<VideoUpload> {
   Timer _timer;
   bool sortBool = true;
   VideoPlayerController _controller;
+  VideoPlayerController _controllerFile;
   // final FijkPlayer player = FijkPlayer();
   // List<String> imagesUrl = [];
   // List<String> videoUrl = [];
@@ -99,14 +100,30 @@ class VideoUploadState extends State<VideoUpload> {
     print(key);
     print(333);
     try {
-      var _imageFile = await ImagePicker.pickVideo(
+      await ImagePicker.pickVideo(
         source: key == 1 ? ImageSource.camera : ImageSource.gallery,
-      );
-      if (_imageFile != null) {
-        _uploadImage(_imageFile.path);
-        // upLoadFileOnce(_imageFile.path);
-        // setState(() {});
-      }
+      )
+      .then((File f) async{
+        if (f != null) {
+        _controllerFile = VideoPlayerController.file(f);
+        _controllerFile.initialize().then((val){
+          _controllerFile.setLooping(true);
+          int seconds = _controllerFile.value.duration.inSeconds;
+          print("视频时长:$seconds");
+          int fileSize=f.lengthSync();//单位B
+          print("视频大小:${fileSize}");
+          print("视频大小:${f.path}");
+          if (seconds <= 300) {
+            _uploadImage(f.path);
+            // upLoadFileOnce(_imageFile.path);
+            // setState(() {});
+          }else {
+            toasts("视频时长不能大于5分钟!");
+          }
+        });}
+      })
+      ;
+      
     } catch (e) {
       toasts("没有权限,无法打开相册!");
     }

+ 25 - 12
lib/internal/bbs/page/visit_page.dart

@@ -59,6 +59,7 @@ class VisitPageState extends State<VisitPage> {
   double percent = 0.0;
   String addressName = "";
   VideoPlayerController _controller;
+  VideoPlayerController _controllerFile;
   // String addressName = "湖北省武汉市洪山区武大科技园豪迈大厦,30.46139,114.414463";
   @override
   void initState() {
@@ -185,18 +186,30 @@ class VisitPageState extends State<VisitPage> {
     print(key);
     print(333);
     try {
-      var _imageFile = await ImagePicker.pickVideo(
-          source: key == 1 ? ImageSource.camera : ImageSource.gallery,
-      );
-      if (_imageFile != null) {
-        // print(123);
-        // print(_imageFile);
-        // print(jsonEncode(_imageFile));
-        print(123);
-        _uploadImage(_imageFile.path);
-        // upLoadFileOnceVideo(_imageFile.path);
-        setState(() {});
-      }
+      await ImagePicker.pickVideo(
+        source: key == 1 ? ImageSource.camera : ImageSource.gallery,
+      )
+      .then((File f) async{
+        if (f != null) {
+        _controllerFile = VideoPlayerController.file(f);
+        _controllerFile.initialize().then((val){
+          _controllerFile.setLooping(true);
+          int seconds = _controllerFile.value.duration.inSeconds;
+          print("视频时长:$seconds");
+          int fileSize=f.lengthSync();//单位B
+          print("视频大小:${fileSize}");
+          print("视频大小:${f.path}");
+          if (seconds <= 300) {
+            _uploadImage(f.path);
+            // upLoadFileOnce(_imageFile.path);
+            // setState(() {});
+          }else {
+            toasts("视频时长不能大于5分钟!");
+          }
+        });}
+      })
+      ;
+      
     } catch (e) {
       toasts("没有权限,无法打开相册!");
     }

+ 222 - 16
lib/internal/wode/page/order_master/confirm_order.dart

@@ -8,7 +8,17 @@ import 'package:image_picker/image_picker.dart';
 import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:liftmanager/internal/wode/wode_router.dart';
 import 'package:permission_handler/permission_handler.dart';
-// import 'package:amap_all_fluttify/amap_all_fluttify.dart';
+import 'package:liftmanager/utils/oss_upload.dart';
+import 'dart:async';
+import 'package:liftmanager/utils/fast_notification.dart';
+import 'package:chewie/chewie.dart';
+import 'package:flutter/services.dart';
+import 'package:liftmanager/utils/utils.dart';
+import 'package:orientation/orientation.dart';
+import 'package:video_player/video_player.dart';
+import 'package:liftmanager/utils/theme_utils.dart';
+import 'package:liftmanager/widgets/selected_video_change.dart';
+import 'dart:io';
 
 class ConfirmOrder extends StatefulWidget {
   ConfirmOrder(this.id);
@@ -22,8 +32,15 @@ class ConfirmOrder extends StatefulWidget {
 }
 
 class ConfirmOrderState extends State<ConfirmOrder> {
+  VideoPlayerController _controller;
+  VideoPlayerController _controllerFile;
+  // final FijkPlayer player = FijkPlayer();
+  // List<String> imagesUrl = [];
+  // List<String> videoUrl = [];
   String videoUrl;
+  String str;
   String imagesUrl;
+  double percent = 0.0;
 
   @override
   void initState() {
@@ -56,18 +73,81 @@ class ConfirmOrderState extends State<ConfirmOrder> {
   }
 
   void _getImage(int key) async {
+    print(key);
+    print(333);
     try {
-      var _imageFile = await ImagePicker.pickVideo(
+      await ImagePicker.pickVideo(
         source: key == 1 ? ImageSource.camera : ImageSource.gallery,
-      );
-      if (_imageFile != null) {
-        upLoadFileOnce(_imageFile.path);
-      }
+      )
+      .then((File f) async{
+        if (f != null) {
+        _controllerFile = VideoPlayerController.file(f);
+        _controllerFile.initialize().then((val){
+          _controllerFile.setLooping(true);
+          int seconds = _controllerFile.value.duration.inSeconds;
+          print("视频时长:$seconds");
+          int fileSize=f.lengthSync();//单位B
+          print("视频大小:${fileSize}");
+          print("视频大小:${f.path}");
+          if (seconds <= 300) {
+            _uploadImage(f.path);
+            // upLoadFileOnce(_imageFile.path);
+            // setState(() {});
+          }else {
+            toasts("视频时长不能大于5分钟!");
+          }
+        });}
+      })
+      ;
+      
     } catch (e) {
       toasts("没有权限,无法打开相册!");
     }
   }
 
+  void _uploadImage(filePath) async {
+    showPercent(context, (){
+      dismissLoading(context);
+      toasts("上传失败");
+    },(){
+      if(videoUrl == null && str != null){
+        setState(() {
+            videoUrl = str;
+            print("videoUrl:"+videoUrl);
+            dismissLoading(context);
+            toasts("上传成功");
+          });
+      }
+    });
+    String uploadName = OssUtil.instance.getImageUploadName(filePath);
+    await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
+      if (data.statusCode == 200) {
+        str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
+        print("str:"+str);
+        print(videoUrl);
+        if(str != null){
+          Map obj = {
+            "uploadName":uploadName,
+            "success":true
+          };
+          FastNotification.push("percent",obj);
+        }
+      }else {
+        Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+        FastNotification.push("percent",obj);
+      }
+    }).catchError((data) {
+      Map obj = {
+            "uploadName":uploadName,
+            "success":false
+          };
+      FastNotification.push("percent",obj);
+    });
+  }
+
   upLoadFileOnce(path) {
     showLoading(context, "正在上传...");
     NewApiService().upload(path, onSuccess: (res) {
@@ -124,7 +204,7 @@ class ConfirmOrderState extends State<ConfirmOrder> {
                 children: <Widget>[
                   Container(
                 width: width,
-                padding: EdgeInsets.only(left:15),
+                padding: EdgeInsets.only(left:15,bottom:15),
                 child: Text(
                                                         "(建议时长3分钟,建议大小50M)",
                                                         style: TextStyle(
@@ -136,25 +216,76 @@ class ConfirmOrderState extends State<ConfirmOrder> {
                                                             textAlign: TextAlign.left,
                                                       ),
               ),
+                  // Container(
+                  //   color: Colors.white,
+                  //   child: GridView.builder(
+                  //     shrinkWrap: true,
+                  //     padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
+                  //     physics: NeverScrollableScrollPhysics(),
+                  //     gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+                  //         crossAxisCount: 3, childAspectRatio: 1.18),
+                  //     itemCount: 1,
+                  //     itemBuilder: (_, index) {
+                  //       return Stack(
+                  //         children: <Widget>[
+                  //           Center(
+                  //             child: SelectedImage(
+                  //               image: imagesUrl,
+                  //               index: index,
+                  //               onTap: () {
+                  //                 selectPicker();
+                  //                 FocusScope.of(context).requestFocus(FocusNode());
+                  //               },
+                  //             ),
+                  //           ),
+                  //           videoUrl != null
+                  //               ? Positioned(
+                  //                   top: 0,
+                  //                   right: 0,
+                  //                   child: GestureDetector(
+                  //                     onTap: () {
+                  //                       print(index);
+                  //                       videoUrl = null;
+                  //                       imagesUrl = null;
+                  //                       setState(() {});
+                  //                     },
+                  //                     child: Icon(
+                  //                       IconData(0xe62a, fontFamily: "myfont"),
+                  //                       size: 24.0,
+                  //                       color: Color(0xff999999),
+                  //                     ),
+                  //                   ),
+                  //                 )
+                  //               : Container(
+                  //                   child: null,
+                  //                 )
+                  //         ],
+                  //       );
+                  //     },
+                  //   ),
+                  // ),
                   Container(
-                    color: Colors.white,
+                    color: ThemeUtils.getDialogTextFieldColor(context),
                     child: GridView.builder(
                       shrinkWrap: true,
                       padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
                       physics: NeverScrollableScrollPhysics(),
                       gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
-                          crossAxisCount: 3, childAspectRatio: 1.18),
+                          crossAxisCount: 1, childAspectRatio: 1.18),
                       itemCount: 1,
                       itemBuilder: (_, index) {
                         return Stack(
                           children: <Widget>[
                             Center(
-                              child: SelectedImage(
-                                image: imagesUrl,
+                              child: SelectedVideo(
+                                image: videoUrl,
                                 index: index,
+                                videoPlay:videoPlay(),
                                 onTap: () {
-                                  selectPicker();
-                                  FocusScope.of(context).requestFocus(FocusNode());
+                                  if(videoUrl == null){
+                                    selectPicker();
+                                  }
+                                  
                                 },
                               ),
                             ),
@@ -165,9 +296,14 @@ class ConfirmOrderState extends State<ConfirmOrder> {
                                     child: GestureDetector(
                                       onTap: () {
                                         print(index);
-                                        videoUrl = null;
-                                        imagesUrl = null;
-                                        setState(() {});
+                                        
+                                        // imagesUrl = null;
+                                        setState(() {
+                                          videoUrl = null;
+                                          str = null;
+                                          _controller.pause();
+                                          // player.reset();
+                                        });
                                       },
                                       child: Icon(
                                         IconData(0xe62a, fontFamily: "myfont"),
@@ -222,4 +358,74 @@ class ConfirmOrderState extends State<ConfirmOrder> {
       ),
     );
   }
+
+  Widget videoPlay() {
+    
+    _controller = VideoPlayerController.network(
+                                        Utils.getImagePath(videoUrl) 
+                                        // imgFontUrl + detailObj.url
+                                        );
+    double width = MediaQuery.of(context).size.width;
+    return 
+    // Container(
+    //                     width: width,
+    //                     height: width*0.6,
+    //                     alignment: Alignment.center,
+    //                     child: FijkView(
+    //                       player: player,
+    //                       color: Colors.black,
+    //                       fit:FijkFit.fill,
+    //                       // cover: NetworkImage(detailObj.cover),
+    //                       // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
+    //                       // 
+    //                     ),
+    //                   );
+    Container(
+                          padding: EdgeInsets.only(
+                              left: ScreenUtil().setWidth(15),
+                              right: ScreenUtil().setWidth(15),
+                              top: ScreenUtil().setWidth(15)),
+                          child: ClipRRect(
+                            borderRadius: BorderRadius.circular(5),
+                            child: 
+                            new Chewie(
+                              controller: ChewieController(
+                                videoPlayerController:
+                                    // VideoPlayerController.network(
+                                    //     imgFontUrl + detailObj.url
+                                    //     ),
+                                    _controller,
+                                aspectRatio: 3 / 2,
+                                allowFullScreen:false,
+                                autoPlay: false,
+                                looping: true,
+                                // startAt: Duration(seconds: 1,minutes: 1),
+                                showControls: true,
+                                deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
+                                // 占位图
+                                // placeholder: Image.network(
+                                //     imgFontUrl+detailObj.cover,
+                                //     fit: BoxFit.contain,
+
+                                //   ),
+
+                                // 是否在 UI 构建的时候就加载视频
+                                autoInitialize: true,
+
+                                // 拖动条样式颜色
+                                materialProgressColors:
+                                    new ChewieProgressColors(
+                                  playedColor: Colors.red,
+                                  handleColor: Colors.blue,
+                                  backgroundColor: Colors.grey,
+                                  bufferedColor: Colors.lightGreen,
+                                ),
+                              ),
+                            ),
+
+                            
+                            
+                          )
+                      );
+  }
 }

+ 27 - 7
lib/internal/wode/page/order_master/punchin.dart

@@ -1,5 +1,5 @@
 import 'dart:async';
-
+import 'dart:io';
 import 'package:amap_location_flutter_plugin/amap_location_flutter_plugin.dart';
 import 'package:amap_location_flutter_plugin/amap_location_option.dart';
 import 'package:flutter/material.dart';
@@ -116,6 +116,7 @@ class PunchinState extends State<Punchin> {
   }
 
   VideoPlayerController _controller;
+  VideoPlayerController _controllerFile;
   ///选择图片
   void selectPicker() {
     showDialog(
@@ -142,14 +143,33 @@ class PunchinState extends State<Punchin> {
   }
 
   void _getImage(int key) async {
+    print(key);
+    print(333);
     try {
-      var _imageFile = await ImagePicker.pickVideo(
+      await ImagePicker.pickVideo(
         source: key == 1 ? ImageSource.camera : ImageSource.gallery,
-      );
-      if (_imageFile != null) {
-        // upLoadFileOnce(_imageFile.path);
-        _uploadImage(_imageFile.path);
-      }
+      )
+      .then((File f) async{
+        if (f != null) {
+        _controllerFile = VideoPlayerController.file(f);
+        _controllerFile.initialize().then((val){
+          _controllerFile.setLooping(true);
+          int seconds = _controllerFile.value.duration.inSeconds;
+          print("视频时长:$seconds");
+          int fileSize=f.lengthSync();//单位B
+          print("视频大小:${fileSize}");
+          print("视频大小:${f.path}");
+          if (seconds <= 300) {
+            _uploadImage(f.path);
+            // upLoadFileOnce(_imageFile.path);
+            // setState(() {});
+          }else {
+            toasts("视频时长不能大于5分钟!");
+          }
+        });}
+      })
+      ;
+      
     } catch (e) {
       toasts("没有权限,无法打开相册!");
     }

+ 25 - 15
lib/internal/wode/page/video/video_upload.dart

@@ -59,6 +59,7 @@ class VideoUploadState extends State<VideoUpload> {
   //  List<String> videoUrl = [];
    VideoDetailModel detailObj;
   VideoPlayerController _controller;
+  VideoPlayerController _controllerFile;
   String videoUrl;
   String str;
   String imagesUrl;
@@ -162,21 +163,30 @@ class VideoUploadState extends State<VideoUpload> {
     print(key);
     print(333);
     try {
-      var _imageFile = await ImagePicker.pickVideo(
-          source: key == 1 ? ImageSource.camera : ImageSource.gallery,
-      );
-      if (_imageFile != null) {
-        // print(123);
-        // print(_imageFile);
-        // print(jsonEncode(_imageFile));
-        LogUtil.d(_imageFile);
-        LogUtil.d(_imageFile.hashCode);
-        LogUtil.d(_imageFile.path);
-        print(123);
-        // upLoadFileOnce(_imageFile.path);
-        _uploadImage(_imageFile.path);
-        setState(() {});
-      }
+      await ImagePicker.pickVideo(
+        source: key == 1 ? ImageSource.camera : ImageSource.gallery,
+      )
+      .then((File f) async{
+        if (f != null) {
+        _controllerFile = VideoPlayerController.file(f);
+        _controllerFile.initialize().then((val){
+          _controllerFile.setLooping(true);
+          int seconds = _controllerFile.value.duration.inSeconds;
+          print("视频时长:$seconds");
+          int fileSize=f.lengthSync();//单位B
+          print("视频大小:${fileSize}");
+          print("视频大小:${f.path}");
+          if (seconds <= 300) {
+            _uploadImage(f.path);
+            // upLoadFileOnce(_imageFile.path);
+            // setState(() {});
+          }else {
+            toasts("视频时长不能大于5分钟!");
+          }
+        });}
+      })
+      ;
+      
     } catch (e) {
       toasts("没有权限,无法打开相册!");
     }