|
|
|
import 'dart:io';
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
...
|
...
|
@@ -16,6 +17,7 @@ import 'package:one_key/widgets/h_empty_view.dart'; |
|
|
|
import 'package:one_key/widgets/round_button.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:video_player/video_player.dart';
|
|
|
|
|
|
...
|
...
|
@@ -30,6 +32,7 @@ import '../../online_check/photo_view_wiget.dart'; |
|
|
|
// import 'package:fijkplayer/fijkplayer.dart';
|
|
|
|
// import 'package:video_thumbnail/video_thumbnail.dart';
|
|
|
|
import 'package:cached_video_player/cached_video_player.dart';
|
|
|
|
import 'package:video_thumbnail/video_thumbnail.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 评价管理
|
|
...
|
...
|
@@ -48,12 +51,6 @@ class _CommentManageHomePageState extends State<CommentManageHomePage> { |
|
|
|
String label = '';
|
|
|
|
|
|
|
|
TextEditingController replyController = TextEditingController();
|
|
|
|
// 声明控制器(两个)
|
|
|
|
CachedVideoPlayerController videoPlayerController;
|
|
|
|
// ChewieController chewieController;
|
|
|
|
// final FijkPlayer player = FijkPlayer();
|
|
|
|
// VideoPlayerController _controller;
|
|
|
|
Future _initializeVideoPlayerFuture;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
...
|
...
|
@@ -181,6 +178,19 @@ class _CommentManageHomePageState extends State<CommentManageHomePage> { |
|
|
|
// return data;
|
|
|
|
// }
|
|
|
|
|
|
|
|
Future<String> getThumbnailFile(
|
|
|
|
List<CommentsImageModel> imags, int index) async {
|
|
|
|
final fileName = await VideoThumbnail.thumbnailFile(
|
|
|
|
video: imags[index].url,
|
|
|
|
thumbnailPath: (await getTemporaryDirectory()).path,
|
|
|
|
// imageFormat: ImageFormat.WEBP,
|
|
|
|
// maxHeight:
|
|
|
|
// 64, // specify the height of the thumbnail, let the width auto-scaled to keep the source aspect ratio
|
|
|
|
quality: 100,
|
|
|
|
);
|
|
|
|
return fileName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 九宫格
|
|
|
|
Widget _getGridImg(List<CommentsImageModel> imags) {
|
|
|
|
imags.removeWhere((element) => element.url == null || element.url == '');
|
|
...
|
...
|
@@ -201,59 +211,143 @@ class _CommentManageHomePageState extends State<CommentManageHomePage> { |
|
|
|
//子组件宽高长度比例
|
|
|
|
childAspectRatio: 1.0),
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
if (imags[index].avinfo != null) {
|
|
|
|
videoPlayerController =
|
|
|
|
CachedVideoPlayerController.network(imags[index].url);
|
|
|
|
videoPlayerController.setLooping(false);
|
|
|
|
_initializeVideoPlayerFuture = videoPlayerController.initialize();
|
|
|
|
if (imags[index].avinfo != null &&
|
|
|
|
imags[index].avinfo != 'false' &&
|
|
|
|
imags[index].avinfo != '0') {
|
|
|
|
// 声明控制器(两个)
|
|
|
|
// imags[index].videoPlayerController =
|
|
|
|
// CachedVideoPlayerController.network(imags[index].url);
|
|
|
|
// // ChewieController chewieController;
|
|
|
|
// // final FijkPlayer player = FijkPlayer();
|
|
|
|
// // VideoPlayerController _controller;
|
|
|
|
// imags[index].initializeVideoPlayerFuture =
|
|
|
|
// imags[index].videoPlayerController.initialize();
|
|
|
|
|
|
|
|
// imags[index].videoPlayerController.setLooping(false);
|
|
|
|
|
|
|
|
// final fileName = _getThumbnailFile(imags, index);
|
|
|
|
|
|
|
|
//视频
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
PopRoute(
|
|
|
|
child: VideoPage(
|
|
|
|
url: imags[index].url,
|
|
|
|
)));
|
|
|
|
},
|
|
|
|
child: Stack(alignment: Alignment.center, children: [
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
child: FutureBuilder(
|
|
|
|
//显示缩略图
|
|
|
|
future: _initializeVideoPlayerFuture,
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
print(snapshot.connectionState);
|
|
|
|
if (snapshot.hasError) print(snapshot.error);
|
|
|
|
if (snapshot.connectionState ==
|
|
|
|
ConnectionState.done) {
|
|
|
|
return AspectRatio(
|
|
|
|
aspectRatio: 1 / 1,
|
|
|
|
// aspectRatio: _controller.value.aspectRatio,
|
|
|
|
// child: VideoPlayer(videoPlayerController),
|
|
|
|
child:
|
|
|
|
CachedVideoPlayer(videoPlayerController));
|
|
|
|
} else {
|
|
|
|
return Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
Positioned(
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath('play'),
|
|
|
|
width: w(20),
|
|
|
|
))
|
|
|
|
]));
|
|
|
|
return FutureBuilder<String>(
|
|
|
|
future: getThumbnailFile(imags, index),
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
PopRoute(
|
|
|
|
child: VideoPage(
|
|
|
|
url: imags[index].url,
|
|
|
|
)));
|
|
|
|
},
|
|
|
|
child: Stack(alignment: Alignment.center, children: [
|
|
|
|
ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
child: AspectRatio(
|
|
|
|
// borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
aspectRatio: 1,
|
|
|
|
child: Image.file(
|
|
|
|
File(snapshot.data),
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
scale: 1,
|
|
|
|
),
|
|
|
|
|
|
|
|
// width: w(),
|
|
|
|
// height: ScreenUtil().setWidth(100 * 2),
|
|
|
|
)),
|
|
|
|
Positioned(
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath('play'),
|
|
|
|
width: w(20),
|
|
|
|
))
|
|
|
|
]));
|
|
|
|
} else if (snapshot.hasError) {
|
|
|
|
return SizedBox();
|
|
|
|
// return Center(
|
|
|
|
// child: CircularProgressIndicator(),
|
|
|
|
// );
|
|
|
|
} else {
|
|
|
|
return SizedBox();
|
|
|
|
// return Center(
|
|
|
|
// child: CircularProgressIndicator(),
|
|
|
|
// );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
// return InkWell(
|
|
|
|
// onTap: () {
|
|
|
|
// Navigator.push(
|
|
|
|
// context,
|
|
|
|
// PopRoute(
|
|
|
|
// child: VideoPage(
|
|
|
|
// url: imags[index].url,
|
|
|
|
// )));
|
|
|
|
// },
|
|
|
|
// child: Stack(alignment: Alignment.center, children: [
|
|
|
|
// ClipRRect(
|
|
|
|
// borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
// child: CachedNetworkImage(
|
|
|
|
// imageUrl: fileName,
|
|
|
|
// fit: BoxFit.cover,
|
|
|
|
|
|
|
|
// // width: w(),
|
|
|
|
// // height: ScreenUtil().setWidth(100 * 2),
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// // ClipRRect(
|
|
|
|
// // borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
// // child: FutureBuilder(
|
|
|
|
// // //显示缩略图
|
|
|
|
// // future: imags[index].initializeVideoPlayerFuture,
|
|
|
|
// // builder: (context, snapshot) {
|
|
|
|
// // print(snapshot.connectionState);
|
|
|
|
// // if (snapshot.hasError) print(snapshot.error);
|
|
|
|
// // if (snapshot.connectionState ==
|
|
|
|
// // ConnectionState.done) {
|
|
|
|
// // ClipRRect(
|
|
|
|
// // borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
// // child: CachedNetworkImage(
|
|
|
|
// // imageUrl: fileName,
|
|
|
|
// // fit: BoxFit.cover,
|
|
|
|
|
|
|
|
// // // width: w(),
|
|
|
|
// // // height: ScreenUtil().setWidth(100 * 2),
|
|
|
|
// // ),
|
|
|
|
// // );
|
|
|
|
// // // return ClipRRect(
|
|
|
|
// // // borderRadius: BorderRadius.circular(r(8)),
|
|
|
|
// // // // aspectRatio: 1 / 1,
|
|
|
|
// // // // aspectRatio: imags[index]
|
|
|
|
// // // // .videoPlayerController
|
|
|
|
// // // // .value
|
|
|
|
// // // // .aspectRatio,
|
|
|
|
// // // // child: VideoPlayer(videoPlayerController),
|
|
|
|
// // // // child: CachedVideoPlayer(
|
|
|
|
// // // // imags[index].videoPlayerController)
|
|
|
|
// // // );
|
|
|
|
// // } else {
|
|
|
|
// // return Center(
|
|
|
|
// // child: CircularProgressIndicator(),
|
|
|
|
// // );
|
|
|
|
// // }
|
|
|
|
// // },
|
|
|
|
// // )),
|
|
|
|
// Positioned(
|
|
|
|
// child: Image.asset(
|
|
|
|
// Utils.getImgPath('play'),
|
|
|
|
// width: w(20),
|
|
|
|
// ))
|
|
|
|
// ]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
List<String> images = [];
|
|
|
|
imags.forEach((element) {
|
|
|
|
if (!element.mimeType.startsWith('video')) {
|
|
|
|
if (element.avinfo == null ||
|
|
|
|
element.avinfo == 'false' ||
|
|
|
|
element.avinfo == '0') {
|
|
|
|
images.add(element.url);
|
|
|
|
}
|
|
|
|
});
|
...
|
...
|
|