Flutter Video player

Amitha C Mohanan
2 min readJan 20, 2021

--

An app to run a video using Flutter.

Flutter provides different packages with which we can build beautiful UI and one among those are the video_player package.
video_player package enables the user to view, pause, play, seek and play the video in full screen. But it doesn’t provide much of user customised controls, so for that flutter supports other different kinds of packages like chewie, better_player, flick_video_player, awsome_video_player etc.

In some of these packages video_player is necessary. Here I will give an example on how flutter videos are played using flick_video_player.

  1. Add the packages video_player: latest version and flick_video_player in the pubspec.yaml file and run flutter pub get.
  2. In main.dart create a StatefulWidget class called CustomVideoPlayer.
  3. Initialise the videocontroller and flickManager.

4. In the initState, initialise the videoPlayerController as
flickManager = FlickManager(videoPlayerController: VideoPlayerController.network(url of the video));

5. In the build method, add the FlickVideoPlayer and if required, you can pass custom controls in it.

To play the video in landscape mode, you can the device orientation in the initState itself.

We can customise the controls in flick_video player using a customised class, or else flick enables by default skip forward, backward, pause, play, fullscreen, and seek the videos.

6. Last step is to dispose all the controllers used in playing the video.

In dispose(), the device orientation is set to normal.

Hope this article help you with your work.

--

--

No responses yet