2

Images can be used inline in websites using <img src=”data:<MIMETYPE>;base64,<BASE64_ENCODED_IMAGE>”>

Does this also work for audio files (e.g. mp3)?

Cyman
  • 123
  • 4
  • Why would you want to do this? Every day I see at least 5-10 posts about using data URIs and I have yet to see a single proper reason for doing so. Almost always, it's folks not understanding how to properly handle blobs in JavaScript. You realize that you're adding 33% overhead to the bandwidth requirements, as well as excess memory and CPU usage for zero benefit? – Brad Apr 21 '20 at 14:24
  • I am creating a single player, offline HTML5 card game - and if it comes just in one (HTML) file, it is easier to use – Cyman Apr 22 '20 at 15:09
  • So now, you're subject to length limits and slowing everything down... again for no benefit. – Brad Apr 22 '20 at 15:10

1 Answers1

1

Short answer yes

long answer

convert your audio file into base64 using either online or other form of tools

ex: src="src="data:audio/ogg;base64,......." />

here is a live link

Za101
  • 451
  • 3
  • 6