video_upload.dart 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/gaps.dart';
  3. import 'package:liftmanager/net/api_service.dart';
  4. import 'package:liftmanager/utils/toast.dart';
  5. import 'package:liftmanager/widgets/app_bar.dart';
  6. import 'package:liftmanager/internal/search/search_router.dart';
  7. import 'package:liftmanager/widgets/app_search_bar.dart';
  8. import 'package:liftmanager/res/resources.dart';
  9. import 'package:liftmanager/routers/fluro_navigator.dart';
  10. import 'package:liftmanager/widgets/load_image.dart';
  11. import 'package:liftmanager/widgets/selected_image_change.dart';
  12. import 'package:image_picker/image_picker.dart';
  13. import 'dart:io';
  14. import 'package:liftmanager/widgets/bbs_content.dart';
  15. import 'package:flutter_screenutil/flutter_screenutil.dart';
  16. import 'package:flutter_spinkit/flutter_spinkit.dart';
  17. import 'package:video_player/video_player.dart';
  18. import 'package:liftmanager/utils/image_utils.dart';
  19. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  20. import 'package:liftmanager/internal/wode/wode_router.dart';
  21. import 'package:liftmanager/internal/bbs/model/video_detail.dart';
  22. import 'package:liftmanager/utils/log_util.dart';
  23. import 'dart:convert';
  24. import 'package:flustars/flustars.dart' as FlutterStars;
  25. import 'package:liftmanager/common/common.dart';
  26. import 'dart:math';
  27. import 'package:liftmanager/utils/fast_notification.dart';
  28. import 'package:liftmanager/utils/theme_utils.dart';
  29. import 'package:liftmanager/utils/oss_upload.dart';
  30. import 'package:liftmanager/utils/log_util.dart';
  31. import 'package:chewie/chewie.dart';
  32. import 'package:flutter/services.dart';
  33. import 'package:liftmanager/utils/utils.dart';
  34. import 'package:orientation/orientation.dart';
  35. import 'dart:async';
  36. import 'package:liftmanager/widgets/selected_video_change.dart';
  37. class VideoUpload extends StatefulWidget {
  38. VideoUpload(this.id);
  39. final String id;
  40. @override
  41. State<StatefulWidget> createState() {
  42. return VideoUploadState();
  43. }
  44. }
  45. class VideoUploadState extends State<VideoUpload> {
  46. // NewsDetailItem item = NewsDetailItem();
  47. ScrollController _scrollController = new ScrollController();
  48. String brandChiose='请选择';
  49. String brandName = "品牌";
  50. int brandIdss;
  51. bool sortBool = true;
  52. // List<String> imagesUrl = [];
  53. // List<String> videoUrl = [];
  54. VideoDetailModel detailObj;
  55. VideoPlayerController _controller;
  56. VideoPlayerController _controllerFile;
  57. String videoUrl;
  58. String str;
  59. String imagesUrl;
  60. double percent = 0.0;
  61. // 焦点控制
  62. FocusNode _focusNode1 = new FocusNode();
  63. GlobalKey _formKey= new GlobalKey<FormState>();
  64. TextEditingController _titleController = new TextEditingController();
  65. TextEditingController _descController = new TextEditingController();
  66. @override
  67. void initState() {
  68. super.initState();
  69. print(widget.id);
  70. if(widget.id!=null&&widget.id!=""){
  71. NewApiService().getVideoDetail(int.parse(widget.id), 1,
  72. onSuccess: (res) {
  73. if (res != null) {
  74. detailObj = res;
  75. LogUtil.d(jsonEncode(res));
  76. print(88885);
  77. setState(() {
  78. videoUrl = null;
  79. videoUrl = res.url;
  80. _titleController.text = res.title;
  81. _descController.text = res.descr;
  82. brandIdss = res.brandId;
  83. brandChiose = res.brandName;
  84. });
  85. }
  86. }, onError: (code, msg) {
  87. toasts(msg);
  88. });
  89. }
  90. }
  91. upLoadFileOnce(path) {
  92. showLoading(context, "正在上传...");
  93. NewApiService().upload(path, onSuccess: (res) {
  94. // imagesUrl.add(res.path);
  95. dismissLoading(context);
  96. setState(() {
  97. // videoUrl = [];
  98. // imagesUrl = [];
  99. // videoUrl.add(res.pathUrl);
  100. // imagesUrl.add(res.coverUrl);
  101. });
  102. }, onError: (code, msg) {
  103. dismissLoading(context);
  104. toasts(msg);
  105. });
  106. }
  107. randomInt(int min, int max) {
  108. return new Random().nextInt(max) % (max - min + 1) + min;
  109. }
  110. List<dynamic> brandList;
  111. Future getBrandList() async {
  112. await NewApiService().getBrandListNoPage(
  113. onSuccess: (res) {
  114. if (res != null) {
  115. brandList = res;
  116. setState(() {});
  117. }
  118. }, onError: (code, msg) {
  119. toasts(msg);
  120. });
  121. }
  122. ///选择视频
  123. void selectPicker() {
  124. showDialog(
  125. context: context,
  126. builder: (BuildContext context) {
  127. return SimpleDialog(
  128. title: Text("选择方式"),
  129. children: ["拍照", '从手机相册选择'].map((String value) {
  130. print("$value");
  131. return SimpleDialogOption(
  132. child: Text(
  133. "${value}",
  134. style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
  135. ),
  136. onPressed: () {
  137. _getImage(value == '拍照' ? 1 : 0);
  138. Navigator.of(context).pop();
  139. },
  140. );
  141. }).toList());
  142. });
  143. }
  144. void _getImage(int key) async {
  145. print(key);
  146. print(333);
  147. try {
  148. await ImagePicker.pickVideo(
  149. source: key == 1 ? ImageSource.camera : ImageSource.gallery,
  150. )
  151. .then((File f) async{
  152. if (f != null) {
  153. _controllerFile = VideoPlayerController.file(f);
  154. _controllerFile.initialize().then((val){
  155. _controllerFile.setLooping(true);
  156. int seconds = _controllerFile.value.duration.inSeconds;
  157. print("视频时长:$seconds");
  158. int fileSize=f.lengthSync();//单位B
  159. print("视频大小:${fileSize}");
  160. print("视频大小:${f.path}");
  161. if (seconds <= 300) {
  162. _uploadImage(f.path);
  163. // upLoadFileOnce(_imageFile.path);
  164. // setState(() {});
  165. }else {
  166. toasts("视频时长不能大于5分钟!");
  167. }
  168. });}
  169. })
  170. ;
  171. } catch (e) {
  172. toasts("没有权限,无法打开相册!");
  173. }
  174. }
  175. void _uploadImage(filePath) async {
  176. showPercent(context, (){
  177. dismissLoading(context);
  178. toasts("上传失败");
  179. },(){
  180. if(videoUrl == null && str != null){
  181. setState(() {
  182. videoUrl = str;
  183. print("videoUrl:"+videoUrl);
  184. dismissLoading(context);
  185. toasts("上传成功");
  186. });
  187. }
  188. });
  189. String uploadName = OssUtil.instance.getImageUploadName(filePath);
  190. await NewApiService.uploadImage(context, uploadName, filePath).then((data) {
  191. if (data.statusCode == 200) {
  192. str = NewApiUrl.URL_UPLOAD_IMAGE_OSS + "/" + uploadName;
  193. print("str:"+str);
  194. print(videoUrl);
  195. if(str != null){
  196. Map obj = {
  197. "uploadName":uploadName,
  198. "success":true
  199. };
  200. FastNotification.push("percent",obj);
  201. }
  202. }else {
  203. Map obj = {
  204. "uploadName":uploadName,
  205. "success":false
  206. };
  207. FastNotification.push("percent",obj);
  208. }
  209. }).catchError((data) {
  210. Map obj = {
  211. "uploadName":uploadName,
  212. "success":false
  213. };
  214. FastNotification.push("percent",obj);
  215. });
  216. }
  217. FocusNode focusNode1 = new FocusNode();
  218. @override
  219. Widget build(BuildContext context) {
  220. double width = MediaQuery.of(context).size.width;
  221. double height = MediaQuery.of(context).size.height;
  222. // 监听FocusNode
  223. _focusNode1.addListener((){
  224. // _focusNode1.hasFocus 是否聚焦
  225. print(_focusNode1.hasFocus);
  226. });
  227. return Scaffold(
  228. resizeToAvoidBottomPadding: false,//不让键盘弹上去
  229. appBar: MyAppBar(
  230. centerTitle: "上传视频",
  231. ),
  232. body:GestureDetector(
  233. onTap: () {
  234. // 点击空白页面关闭键盘
  235. FocusScope.of(context).requestFocus(focusNode1);
  236. },
  237. child: Stack(
  238. children: <Widget>[
  239. Container(
  240. child: ListView(
  241. children: <Widget>[
  242. Form(
  243. key: _formKey, //设置globalKey,用于后面获取FormState
  244. // autovalidate: true, //开启自动校验
  245. child: Column(
  246. children: <Widget>[
  247. ChioseThisRight(label: "电梯品牌",value:brandChiose,fun:(){
  248. setState(() {
  249. // brandChiose = brandListChiose[index];
  250. sortBool = false;
  251. print(5656333);
  252. });
  253. getBrandList();
  254. // Navigator.maybePop(context);
  255. }),
  256. Row(
  257. crossAxisAlignment: CrossAxisAlignment.start,
  258. mainAxisAlignment: MainAxisAlignment.start,
  259. children: <Widget>[
  260. Container(
  261. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  262. child: Text(
  263. "视频标题",
  264. style: TextStyle(
  265. color:Color(0xff222222),
  266. // fontSize:ScreenUtil().setSp(14),
  267. ),
  268. textAlign:TextAlign.left,
  269. ),
  270. ),
  271. ],
  272. ),
  273. Container(
  274. height:80,
  275. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(20)),
  276. child: TextFormField(
  277. // autofocus: true,
  278. maxLength: 50,
  279. cursorColor: Color(0xffcccccc),
  280. controller: _titleController,
  281. maxLines:5,
  282. decoration: InputDecoration(
  283. contentPadding: EdgeInsets.all(0),
  284. hintText: '请输入你上传视频的标题',
  285. hintStyle:TextStyle(
  286. color: Color(0xffcccccc)
  287. ),
  288. focusedBorder: InputBorder.none,
  289. border: InputBorder.none,
  290. // filled: true, // 背景色
  291. // fillColor: Colors.cyan.withAlpha(35),
  292. // icon: Icon(Icons.person)
  293. ),
  294. // 校验
  295. validator: (val) {
  296. return val.trim().length > 0 ? null : "不能为空";
  297. }
  298. ),
  299. ),
  300. SizedBox(
  301. height:6,
  302. child: Container(
  303. color:ThemeUtils.getDialogTextFieldColor(context)
  304. ),
  305. ),
  306. Row(
  307. crossAxisAlignment: CrossAxisAlignment.start,
  308. mainAxisAlignment: MainAxisAlignment.start,
  309. children: <Widget>[
  310. Container(
  311. padding:EdgeInsets.only(left:ScreenUtil().setWidth(15),top:ScreenUtil().setWidth(10),bottom:ScreenUtil().setWidth(5)),
  312. child: Text(
  313. "视频简介",
  314. style: TextStyle(
  315. color:Color(0xff222222),
  316. // fontSize:ScreenUtil().setSp(14),
  317. ),
  318. textAlign:TextAlign.left,
  319. ),
  320. ),
  321. ],
  322. ),
  323. Container(
  324. height:120,
  325. padding: EdgeInsets.only(left:ScreenUtil().setWidth(15),right:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(20)),
  326. child: TextFormField(
  327. // autofocus: true,
  328. maxLength: 500,
  329. cursorColor: Color(0xffcccccc),
  330. controller: _descController,
  331. maxLines:5,
  332. decoration: InputDecoration(
  333. contentPadding: EdgeInsets.all(0),
  334. hintText: '请输入您上传视频的简介',
  335. hintStyle:TextStyle(
  336. color: Color(0xffcccccc)
  337. ),
  338. focusedBorder: InputBorder.none,
  339. border: InputBorder.none,
  340. // filled: true, // 背景色
  341. // fillColor: Colors.cyan.withAlpha(35),
  342. // icon: Icon(Icons.person)
  343. ),
  344. // 校验
  345. validator: (val) {
  346. return val.trim().length > 0 ? null : "不能为空";
  347. }
  348. ),
  349. ),
  350. SizedBox(
  351. height:6,
  352. child: Container(
  353. color:ThemeUtils.getDialogTextFieldColor(context)
  354. ),
  355. ),
  356. Container(
  357. width: width,
  358. padding: EdgeInsets.only(left:15,top:15,bottom:15),
  359. child: Text(
  360. "(建议时长3分钟,建议大小50M)",
  361. style: TextStyle(
  362. color: Colors.red,
  363. fontSize:
  364. ScreenUtil()
  365. .setSp(14),
  366. ),
  367. textAlign: TextAlign.left,
  368. ),
  369. ),
  370. // Container(
  371. // color: ThemeUtils.getTabsBg(context),
  372. // child: GridView.builder(
  373. // shrinkWrap: true,
  374. // padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  375. // physics: NeverScrollableScrollPhysics(),
  376. // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  377. // crossAxisCount: 3, childAspectRatio: 1.18),
  378. // itemCount: videoUrl.length >= 1 ? 1 : videoUrl.length + 1,
  379. // itemBuilder: (_, index) {
  380. // return Stack(
  381. // children: <Widget>[
  382. // Center(
  383. // child: SelectedImage(
  384. // image: index < videoUrl.length ? imagesUrl[index] : null,
  385. // // image: index < videoUrl.length ? videoUrl[index] : null,
  386. // index:index,
  387. // onTap: () {
  388. // if(index >= videoUrl.length){
  389. // selectPicker();
  390. // }
  391. // FocusScope.of(context).requestFocus(FocusNode());
  392. // print(index);
  393. // print(videoUrl);
  394. // }),
  395. // ),
  396. // index < videoUrl.length?Positioned(
  397. // top:0,
  398. // right:0,
  399. // child:GestureDetector(
  400. // onTap: (){
  401. // print(index);
  402. // videoUrl.remove(videoUrl[index]);
  403. // imagesUrl.remove(imagesUrl[index]);
  404. // setState(() {
  405. // });
  406. // },
  407. // child:Icon(
  408. // IconData(
  409. // 0xe62a,
  410. // fontFamily:"myfont"
  411. // ),
  412. // size: 24.0,
  413. // color:Color(0xff999999),
  414. // ),
  415. // )
  416. // ):Container(child: null,)
  417. // ],
  418. // );
  419. // },
  420. // )
  421. // ),
  422. Container(
  423. color: ThemeUtils.getDialogTextFieldColor(context),
  424. child: GridView.builder(
  425. shrinkWrap: true,
  426. padding: const EdgeInsets.fromLTRB(8.0, 12, 8.0, 12.0),
  427. physics: NeverScrollableScrollPhysics(),
  428. gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  429. crossAxisCount: 1, childAspectRatio: 1.18),
  430. itemCount: 1,
  431. itemBuilder: (_, index) {
  432. return Stack(
  433. children: <Widget>[
  434. Center(
  435. child: SelectedVideo(
  436. image: videoUrl,
  437. index: index,
  438. videoPlay:videoPlay(),
  439. onTap: () {
  440. if(videoUrl == null){
  441. selectPicker();
  442. }
  443. },
  444. ),
  445. ),
  446. videoUrl != null
  447. ? Positioned(
  448. top: 0,
  449. right: 0,
  450. child: GestureDetector(
  451. onTap: () {
  452. print(index);
  453. // imagesUrl = null;
  454. setState(() {
  455. videoUrl = null;
  456. str = null;
  457. _controller.pause();
  458. // player.reset();
  459. });
  460. },
  461. child: Icon(
  462. IconData(0xe62a, fontFamily: "myfont"),
  463. size: 24.0,
  464. color: Color(0xff999999),
  465. ),
  466. ),
  467. )
  468. : Container(
  469. child: null,
  470. )
  471. ],
  472. );
  473. },
  474. ),
  475. ),
  476. SizedBox(
  477. height:ScreenUtil().setWidth(80),
  478. ),
  479. ],
  480. ),
  481. )
  482. ]
  483. )
  484. ),
  485. Positioned(
  486. bottom:0,
  487. left:0,
  488. child:Container(
  489. width: width,
  490. padding: EdgeInsets.only(top:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(15),left:ScreenUtil().setWidth(25),right:ScreenUtil().setWidth(25)),
  491. color:ThemeUtils.getDialogTextFieldColor(context),
  492. child: Container(
  493. height:ScreenUtil().setWidth(44),
  494. decoration: BoxDecoration(
  495. borderRadius: BorderRadius.circular(ScreenUtil().setWidth(22)),
  496. gradient: const LinearGradient(
  497. colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  498. ),
  499. child: FlatButton(
  500. // padding: EdgeInsets.all(15.0),
  501. child: Text("提交"),
  502. textColor: Colors.white,
  503. onPressed: () {
  504. if(brandIdss==null){
  505. toasts("请选择品牌");
  506. return;
  507. }
  508. if(videoUrl==null){
  509. toasts("请上传视频");
  510. return;
  511. }
  512. // String videos = videoUrl.join(",");
  513. // String images = imagesUrl.join(",");
  514. if((_formKey.currentState as FormState).validate()){
  515. showLoading(context, "正在提交...");
  516. if(widget.id!=null&&widget.id!=""){
  517. dynamic objEdit = {
  518. "brandId":brandIdss,
  519. "title":_titleController.text,
  520. "descr":_descController.text,
  521. "url":videoUrl,
  522. // "cover": images,
  523. "checkFlag":2,
  524. "statuz":1,
  525. "platformFlag":1,
  526. "userId":FlutterStars.SpUtil.getString(Constant.userId),
  527. "id":detailObj.id
  528. };
  529. NewApiService().editVideo(objEdit, onSuccess: (res) {
  530. dismissLoading(context);
  531. toasts("修改成功");
  532. String initThisMyVideo = randomInt(1111,9999).toString() + DateTime.now().millisecondsSinceEpoch.toString();
  533. FastNotification.push("initMyVideo",initThisMyVideo);
  534. Navigator.of(context)..pop()..pop();
  535. }, onError: (code, msg) {
  536. dismissLoading(context);
  537. toasts(msg);
  538. });
  539. }else {
  540. dynamic obj = {
  541. "brandId":brandIdss,
  542. "title":_titleController.text,
  543. "descr":_descController.text,
  544. "url":videoUrl,
  545. // "cover": images,
  546. "checkFlag":2,
  547. "statuz":1,
  548. "platformFlag":1,
  549. "userId":FlutterStars.SpUtil.getString(Constant.userId)
  550. };
  551. NewApiService().addVideo(obj, onSuccess: (res) {
  552. dismissLoading(context);
  553. toasts("提交成功");
  554. String initThisMyVideo = randomInt(1111,9999).toString() + DateTime.now().millisecondsSinceEpoch.toString();
  555. FastNotification.push("initMyVideo",initThisMyVideo);
  556. Navigator.pop(context);
  557. }, onError: (code, msg) {
  558. dismissLoading(context);
  559. toasts(msg);
  560. });
  561. }
  562. }
  563. },
  564. ),
  565. ),
  566. )
  567. ),
  568. !sortBool?
  569. Positioned(
  570. top:0,
  571. left:0,
  572. child: Container(
  573. width:width,
  574. height:height,
  575. color: Color.fromRGBO(0, 0, 0, 0.5)
  576. )
  577. )
  578. :Container(
  579. child:null
  580. ),
  581. !sortBool?
  582. Positioned(
  583. top:0,
  584. right:0,
  585. child:Container(
  586. width: width/4*3,
  587. height:height,
  588. color: ThemeUtils.getTabsBg(context),
  589. padding: EdgeInsets.all(10),
  590. child:ListView(
  591. children:<Widget>[
  592. Container(
  593. padding: EdgeInsets.only(left:5,top:5,bottom:10),
  594. child:Text(
  595. "品牌",
  596. style: TextStyle(
  597. color:Color(0xff666666),
  598. fontSize:ScreenUtil().setSp(16)
  599. ),
  600. textAlign:TextAlign.start,
  601. ),
  602. ),
  603. brandList!=null&&brandList!=[]?Container(
  604. child: Wrap(
  605. alignment: WrapAlignment.start,
  606. crossAxisAlignment: WrapCrossAlignment.center,
  607. children: brandList.asMap().keys.map((index){
  608. return InkWell(
  609. onTap: (){
  610. print("666");
  611. setState(() {
  612. sortBool = true;
  613. brandChiose = brandList[index].name??"";
  614. brandIdss = brandList[index].id;
  615. });
  616. },
  617. child: Container(
  618. width: width/4-17,
  619. padding: EdgeInsets.only(bottom:ScreenUtil().setWidth(10),top:ScreenUtil().setWidth(10)),
  620. margin: EdgeInsets.only(left:5,right:5,bottom:5,top:5),
  621. decoration: BoxDecoration(
  622. // border: Border(
  623. // bottom: BorderSide(width: 0.5, color: Colours.line),
  624. // ),
  625. color: Color(0xfff5f5f5)
  626. ),
  627. child:Text(
  628. brandList[index].name??"",
  629. style: TextStyle(
  630. color:Color(0xff666666),
  631. fontSize:ScreenUtil().setSp(15)
  632. ),
  633. textAlign:TextAlign.center,
  634. maxLines: 1,
  635. overflow: TextOverflow.ellipsis,
  636. ),
  637. ),
  638. );
  639. }).toList(),
  640. )
  641. ):loadCircle()
  642. ],
  643. )
  644. )
  645. ):
  646. Container(
  647. child:null
  648. ),
  649. ],
  650. ),
  651. ),
  652. );
  653. }
  654. Widget loadCircle() {
  655. return Container(
  656. padding: EdgeInsets.only(top: 10, bottom: 10),
  657. color: ThemeUtils.getTabsBg(context),
  658. child: Center(
  659. child: SpinKitFadingCircle(
  660. color: Colors.blueAccent,
  661. size: 30.0,
  662. ),
  663. ),
  664. );
  665. }
  666. Widget videoPlay() {
  667. _controller = VideoPlayerController.network(
  668. Utils.getImagePath(videoUrl)
  669. // imgFontUrl + detailObj.url
  670. );
  671. double width = MediaQuery.of(context).size.width;
  672. return
  673. // Container(
  674. // width: width,
  675. // height: width*0.6,
  676. // alignment: Alignment.center,
  677. // child: FijkView(
  678. // player: player,
  679. // color: Colors.black,
  680. // fit:FijkFit.fill,
  681. // // cover: NetworkImage(detailObj.cover),
  682. // // cover: new Image(image: detailObj.cover!=null&& detailObj.cover!=""?NetworkImage(detailObj.cover):AssetImage("assets/images/video_image.png"),).image,
  683. // //
  684. // ),
  685. // );
  686. Container(
  687. padding: EdgeInsets.only(
  688. left: ScreenUtil().setWidth(15),
  689. right: ScreenUtil().setWidth(15),
  690. top: ScreenUtil().setWidth(15)),
  691. child: ClipRRect(
  692. borderRadius: BorderRadius.circular(5),
  693. child:
  694. new Chewie(
  695. controller: ChewieController(
  696. videoPlayerController:
  697. // VideoPlayerController.network(
  698. // imgFontUrl + detailObj.url
  699. // ),
  700. _controller,
  701. aspectRatio: 3 / 2,
  702. allowFullScreen:false,
  703. autoPlay: false,
  704. looping: true,
  705. // startAt: Duration(seconds: 1,minutes: 1),
  706. showControls: true,
  707. deviceOrientationsAfterFullScreen:[DeviceOrientation.portraitUp],
  708. // 占位图
  709. // placeholder: Image.network(
  710. // imgFontUrl+detailObj.cover,
  711. // fit: BoxFit.contain,
  712. // ),
  713. // 是否在 UI 构建的时候就加载视频
  714. autoInitialize: true,
  715. // 拖动条样式颜色
  716. materialProgressColors:
  717. new ChewieProgressColors(
  718. playedColor: Colors.red,
  719. handleColor: Colors.blue,
  720. backgroundColor: Colors.grey,
  721. bufferedColor: Colors.lightGreen,
  722. ),
  723. ),
  724. ),
  725. )
  726. );
  727. }
  728. }
  729. class ChioseThisRight extends StatelessWidget {
  730. ChioseThisRight({Key key,this.value,this.label,this.fun,this.labelText='请选择'}) : super(key: key);
  731. String value;
  732. String label;
  733. Function fun;
  734. String labelText;
  735. @override
  736. Widget build(BuildContext context) {
  737. double width = MediaQuery.of(context).size.width;
  738. return InkWell(
  739. onTap: (){
  740. fun();
  741. },
  742. child: Container(
  743. padding: EdgeInsets.only(top:ScreenUtil().setWidth(15),bottom:ScreenUtil().setWidth(15)),
  744. margin: EdgeInsets.only(left:ScreenUtil().setWidth(15)),
  745. decoration: BoxDecoration(
  746. border: Border(
  747. bottom: BorderSide(width: 0.5, color: Colours.line),
  748. ),
  749. ),
  750. child: Row(
  751. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  752. children:<Widget>[
  753. Text(
  754. label,
  755. style: TextStyle(
  756. color:Color(0xff222222),
  757. // fontSize: ScreenUtil().setSp(14)
  758. ),
  759. textAlign:TextAlign.start,
  760. ),
  761. value.isEmpty? Container(
  762. child: Row(
  763. children:<Widget>[
  764. Text(
  765. labelText,
  766. style: TextStyle(
  767. color:Color(0xffcccccc),
  768. // fontSize: ScreenUtil().setSp(14)
  769. ),
  770. textAlign:TextAlign.start,
  771. ),
  772. Container(
  773. padding: EdgeInsets.only(top:3),
  774. child: Icon(
  775. Icons.keyboard_arrow_right,
  776. size: 20.0,
  777. color:Color(0xffcccccc),
  778. ),
  779. ),
  780. SizedBox(
  781. width:10
  782. )
  783. ]
  784. ),
  785. ):
  786. Container(
  787. padding: EdgeInsets.only(right:ScreenUtil().setWidth(15)),
  788. child: Row(
  789. children:<Widget>[
  790. Text(
  791. value,
  792. style: TextStyle(
  793. color:Color(0xff222222),
  794. fontSize: ScreenUtil().setSp(14)
  795. ),
  796. textAlign:TextAlign.start,
  797. ),
  798. ]
  799. ),
  800. ),
  801. ]
  802. ),
  803. ),
  804. );
  805. }
  806. }