video thumbnails extractor añadido

This commit is contained in:
Abraham
2026-01-13 15:08:10 -08:00
parent 8612688aa3
commit 9533b60906
6 changed files with 225 additions and 20 deletions

View File

@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
class VideoScreenThumbnail extends StatefulWidget {
final dynamic video;
const VideoScreenThumbnail({Key? key, required this.video}) : super(key: key);
@override
State<VideoScreenThumbnail> createState() => _VideoScreenThumbnailState();
}
class _VideoScreenThumbnailState extends State<VideoScreenThumbnail> {
late VideoPlayerController _controllerVideo;
late bool startedPlaying;
@override
void initState() {
_controllerVideo = VideoPlayerController.network(widget.video);
_controllerVideo.initialize();
super.initState();
started();
_controllerVideo.setVolume(0);
_controllerVideo.pause();
}
Future<bool> started() async {
var renderized = false;
double height = 0;
await Future.delayed(const Duration(seconds: 2), () {
height = _controllerVideo.value.size.height;
if (height > 0) renderized = true;
});
return renderized;
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: started(),
builder: ((context, AsyncSnapshot<bool> snapshot) {
if (snapshot.data ?? false) {
return Stack(
alignment: AlignmentDirectional.center,
children: [
VideoPlayer(_controllerVideo),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: const [
SizedBox(height: 30),
],
),
],
);
} else {
return const Center(child: CircularProgressIndicator());
}
}),
);
}
@override
void dispose() {
super.dispose();
var video = _controllerVideo;
video.dispose();
}
}