Search code examples
fluttergoogle-cloud-firestorecors

Video download problem with fluter Web when crossOriginIsolated=true


I'm working on a flutter application manipulating images and videos. For video re-encoding I use ffmpeg_wasm and shared buffer which requires crossOriginIsolated. Video encoding works well, downloading and image display also works, however downloading videos from Firebase storage is blocked by the browser because Cross-Origin-Resource-Policy is not-set causing error 206.

To solve this issue i suppose firebase storage should set this header but i don't hunderstand why picture work

Picture of request header using Image.network(myURL)

And video using video_player: ^2.7.1 VideoPlayerController.networkUrl(myURL)

I note Sec-Fetch-Mode is different.


Solution

  • After a day of work i found html video tag work if i add crossorigin="anonymous" proprety.

    So i add this propery in video_player_web.dart file in the lib folder of the plug in

    final VideoElement videoElement = VideoElement()
          ..id = 'videoElement-$textureId'
          ..src = uri
          ..crossOrigin = "anonymous"
          ..style.border = 'none'
          ..style.height = '100%'
          ..style.width = '100%';
    

    and it work