I am using VideoPlayer package to display .mp4 in my app. I am able to loop it very easly just by adding _controller.setLooping(true);
. However I am not able to create a boomerang effect with this package. Do you have any ideas how to implement it?
Here you can get sample code of mine:
class DashboardVideoBackground extends StatefulWidget {
DashboardVideoBackground({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() => _DashboardVideoBackgroundState();
}
class _DashboardVideoBackgroundState extends State<DashboardVideoBackground> {
VideoPlayerController _controller;
Future<void> _initializeVideoPlayerFuture;
@override
void initState() {
_controller =
VideoPlayerController.asset('assets/mock/dashboard_background.mp4');
_initializeVideoPlayerFuture = _controller.initialize();
_controller.setLooping(true);
_controller.play();
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
return FutureBuilder(
future: _initializeVideoPlayerFuture,
builder: (context, snapshot) =>
snapshot.connectionState == ConnectionState.done
? OverflowBox(
maxWidth: double.infinity,
maxHeight: double.infinity,
alignment: Alignment.center,
child: FittedBox(
fit: BoxFit.cover,
alignment: Alignment.center,
child: Container(
width: MediaQuery.of(context).size.width * 1.5,
height: MediaQuery.of(context).size.height,
child: VideoPlayer(_controller),
),
),
)
: Center(child: CircularProgressIndicator()),
);
},
);
}
}