Home > Mobile >  data:// url works on Firefox but not on Chrome?
data:// url works on Firefox but not on Chrome?

Time:03-04

My HTML page contains the following video tag:

<video id="video" src="data://video/mp4;base64,AAAAIGZ0eXBpc29tAAACAG..."></video>

The video tag contains a a base64 version of a 2MB mp4 clip of Big Buck Bunny (truncated in snippet to fit in post).

This loads perfectly fine on Firefox, but doesn't load at all on Chrome, and does not throw any errors to the console. Initially my thought was this error was due to some URL length constraint not met on Firefox but met on chrome, however , my page still does not work on Chrome with smaller source videos. Does anyone know what is causing this issue?

CodePudding user response:

Turns out @code was correct.
My problem was that I messed up the formatting of the data URL by using 2 slashes data://, rather than the correct format of data:

data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAG...

The above finally works on both browsers.
Firefox accepts both formats — while Chrome is more strict about that rule. A bit annoying Chrome doesn't throw any error for it.

  • Related