0

I ave a Flutter app that communicates with a backend python server using websockets. Essentially the app sends a video to the server, the backend does some ML stuff and sends back an mp4 file as a Uint8List. I'm converting that list into a List then creating a temporary File object where I write the data converted. Finally I use this file to play the video with the "video_player" package using the .file method.

Future<void> convertListToVideoFileMobile() async {
    final tempDir = await getTemporaryDirectory();
    final tempPath = tempDir.path;

    // Concatenate the Uint8List chunks into a single Uint8List
    final videoData = Uint8List.fromList(
      videoList.fold<List<int>>([], (prev, curr) => prev..addAll(curr)),
    );

    // Create a new File in the temporary directory and write the video data
    final file = File('$tempPath/myVideo.mp4');
    await file.writeAsBytes(videoData);

    videoFileMobile = file;
  }

The issue is that getting access to a temporary file using Flutter web is denied following my researches.

So I was wondering is there a way to find an alternative process to make this happen.

I did not try a lot to be honest because i didn't find anything in the web nor in stackoverflow but I'm not losing hope.

  • Does this answer your question? [How can I read and Write Files in Flutter Web?](https://stackoverflow.com/questions/57182634/how-can-i-read-and-write-files-in-flutter-web) – user18309290 Jun 22 '23 at 17:53

0 Answers0