fix video thumbnail
This commit is contained in:
@@ -1316,10 +1316,18 @@ class MessageInputState extends State<MessageInput> {
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
child: VideoThumbnail(
|
||||
file: File(
|
||||
attachment.file.path,
|
||||
),
|
||||
child: FutureBuilder<File>(
|
||||
future: VideoCompress.getFileThumbnail(attachment.file.path),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Offstage();
|
||||
}
|
||||
|
||||
return Image.file(
|
||||
snapshot.data,
|
||||
fit: BoxFit.cover,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
class VideoThumbnail extends StatefulWidget {
|
||||
final File file;
|
||||
|
||||
const VideoThumbnail({
|
||||
Key key,
|
||||
@required this.file,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_VideoThumbnailState createState() => _VideoThumbnailState();
|
||||
}
|
||||
|
||||
class _VideoThumbnailState extends State<VideoThumbnail> {
|
||||
VideoPlayerController _videoPlayerController;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return VideoPlayer(_videoPlayerController);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_videoPlayerController = VideoPlayerController.file(widget.file)
|
||||
..initialize();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_videoPlayerController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user