I want to create a VideoPlayer class for my flutter application, where I can put a looping video. When I debug the app or I m running it in "release mode", the VideoPlayer shows only the first frame of the video.
This is the code from my videoplayer.dart file
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:video_player/video_player.dart';
class clipVideo extends StatefulWidget {
clipVideo() : super();
final String title = "titlu video";
@override
_clipVideo createState() => _clipVideo();
}
class _clipVideo extends State<clipVideo> {
VideoPlayerController _controller;
Future<void> _initializeVideoPlayerFuture;
@override
void initState() {
_controller = VideoPlayerController.asset('assets/videos/intro.mp4');
_initializeVideoPlayerFuture = _controller.initialize();
_controller.setLooping(true);
_controller.setVolume(1.0);
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
child: FutureBuilder(
future: _initializeVideoPlayerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Center(
child: AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
),
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
);
}
}
here is my dependency from the public.yasml file
video_player: ^0.10.11
The flutter run has no errors whatsoever. Is it because the video has the size of 20MB?
Include in initState()
_controller.play();