Commit 9366adbc3e6b25bc1a6122a4fc463ae21efd20b8

Authored by wdn127929
1 parent 9b68d353

修复评论管理页面视频封面显示问题

... ... @@ -18,19 +18,19 @@ if (flutterRoot == null) {
def flutterVersionCode = "512"
def flutterVersionCode = "513"
if (flutterVersionCode == null) {
flutterVersionCode = '512'
flutterVersionCode = '513'
}
def flutterVersionName = "5.1.2"
def flutterVersionName = "5.1.3"
if (flutterVersionName == null) {
flutterVersionName = '5.1.2'
flutterVersionName = '5.1.3'
}
... ...
import 'dart:convert';
import 'package:cached_video_player/cached_video_player.dart';
import 'package:common_utils/common_utils.dart';
class CommentsModel {
... ... @@ -210,6 +211,8 @@ class CommentsImageModel {
ImageAve imageAve;
String url;
String avinfo;
CachedVideoPlayerController videoPlayerController;
Future initializeVideoPlayerFuture;
CommentsImageModel(
{this.key,
... ...
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);
}
});
... ...
... ... @@ -1505,6 +1505,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.10"
video_thumbnail:
dependency: "direct main"
description:
name: video_thumbnail
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.5.3"
wakelock:
dependency: transitive
description:
... ...
... ... @@ -145,7 +145,7 @@ dependencies:
#苹果登陆
# sign_in_with_apple: ^3.0.0
sign_in_with_apple: 4.2.0
# video_thumbnail: ^0.5.3
video_thumbnail: ^0.5.3
# video_player: ^2.4.7
# video_player: ^2.7.0
# video_player: ^2.4.2
... ...