I saved a video in my asset folder and i am trying to get the video using the File class.
For example:
Final File video = File(String path);
So my question is where can i find the String path?
I already added this file to the pubspec.yaml
assets:
- assets/mbf.mp4
Thank you
Answer
getVideo() async {
var response = await rootBundle.load('assets/mbf.mp4');
final directory = await getApplicationDocumentsDirectory();
var file = File("${directory.path}/mbf.mp4");
file.writeAsBytesSync(response.buffer.asUint8List());
//Use it with VideoPlayer
controller = VideoPlayerController.file(file)
..addListener(() => setState(() {}))
..setLooping(true)
..initialize().then((_) => controller.play());
}