-2

How to download video from online(api response) and store it in local device and play that video using video player in flutter app. Eg : Amazon Prime, Youtube, Netflix...

Aravind B
  • 87
  • 1
  • 3

1 Answers1

1

On an outline to give you an idea, you would need to consider

  1. Download video, use dio to download your video files to your local path.

ex.

 try {
    var dir = await getApplicationDocumentsDirectory();
    await dio.download(url, "${dir.path}/myFile.mp4", onProgress: (rec, total) {
      print("Rec: $rec , Total: $total");
    });
  } catch (e) {

We could use path_provider to get the applicationDocumentDirectory to save the files to local dir.

  1. DB to save the files path of locally saved files, you could use objectdb, hive

  2. Use the video_player plugin to play the asset file saved locally.

epynic
  • 1,124
  • 2
  • 14
  • 26