Spencer
Spencer

Reputation: 113

Flutter VideoPlayer doesn't support download url from Firebase Cloud Storage?

final MyFile file; //url is the downloadurl from Firebase Cloud Storage

_videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(file.url));
_initVideoPlayerController = _videoPlayerController.initialize();

...

return FutureBuilder(
future: _initVideoPlayerController,
builder: (context, snap) {
return AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: VideoPlayer(_videoPlayerController),
);
});

...

Error: flutter: PlatformException(VideoError, Failed to load video: Cannot Open, null, null)


The download Url from Firebase Cloud Storage ins't accepted as an accepted file format with VideoPlayer, is there a way to use the videos saved in Cloud Storage without downloading them to local storage?

I've used this same setup with asset videos and it was successful. Ive also used url formats with https://...mp4 and it was also successful. However, anything without the extension .mp4, i get this error. Some videos with the mp4 also don't work.

Upvotes: -1

Views: 70

Answers (1)

vivideradicator
vivideradicator

Reputation: 56

This is expected behaviour.

This is called an HTTP progressive download where the URL is the direct path to your video file (e.g. .mp4). Essentially, what the video player is doing is downloading parts of your video into some storage on your device and playing that chunk.

What won't work is playing a webpage with a video (e.g. a YouTube video). In HTML, this means that if you have a <video> tag surrounded by <body> or other html elements, the player will not know what to play, and instead you should look for what is directly in the src property of the <video> tag instead.

For more complex tasks, you can look into other forms of video streaming. Such as HLS, WebRTC, etc.

Upvotes: 0

Related Questions