html2apk Get the app

Audio and video inside an HTML app

Sound effects, a soundboard, a training video, a product clip — all work in an HTML APK. The questions are which formats, when playback may start, and how much media fits.

Updated 12 October 2026By HTML2APK Editorial Team7 min read
Short answer

In an HTML app on Android, bundle audio as MP3, AAC (M4A) or Ogg/Opus and video as MP4 (H.264 + AAC) or WebM, start playback from a user tap (or muted for video autoplay), unlock Web Audio on the first touch for games, and keep total media small — the free builder accepts 5 MB of zipped content and Pro 18 MB; larger media should stream from a server.

Key takeaways

  • MP3 and MP4/H.264 play on every Android WebView.
  • Start sound from a tap; muted video with playsinline can autoplay.
  • Audio pauses when the app goes to the background.
  • Media dominates APK size — compress hard or stream.

Formats that always work

TypeUseNotes
MP3Music, voice, effectsUniversal; 96–128 kbps is plenty for voice
AAC / M4AMusicBetter quality per KB than MP3
Ogg OpusVoice, effectsSmallest files for speech
MP4 (H.264 + AAC)VideoHardware-decoded on every phone
WebM (VP9)VideoSmaller; decoding support varies on older phones

Autoplay rules

Like Chrome, a WebView can refuse to start sound that the user did not trigger. Reliable patterns:

<!-- background or hero video: muted autoplay is allowed --> <video src="media/intro.mp4" autoplay muted loop playsinline poster="img/intro.jpg"></video> <!-- sound: start from a tap --> <button id="play">Play</button> <script> const a = new Audio('media/welcome.mp3'); play.onclick = () => a.play().catch(err => console.warn('blocked', err)); </script>

Games: unlock Web Audio on first touch

const ctx = new (window.AudioContext || window.webkitAudioContext)(); addEventListener('pointerdown', function unlock() { if (ctx.state === 'suspended') ctx.resume(); removeEventListener('pointerdown', unlock); }, { once: true });

Decode short effects once with ctx.decodeAudioData and replay the buffers — creating a new Audio element per shot causes lag on low-end phones. Most game engines (Phaser, PixiJS sound, Howler.js) do this for you.

Background and lock screen

When the user leaves the app or locks the phone, the WebView pauses, and playback stops. HTML apps are not suited to background music players or podcasts; use a native app for those. Pause your own media on visibilitychange so it resumes cleanly.

Keeping media small

  • Voice: mono, 64 kbps Opus or 96 kbps MP3.
  • Video: 720p is plenty on a phone; target 1–2 Mbps H.264. Ten seconds is about 2 MB.
  • Over the size limit? Host the video on a server or video platform and stream it — it will need a connection.

Estimate before you build with how big an HTML APK is.

Frequently asked questions

Why doesn't my audio play in the app?

Playback was probably started without a user tap and blocked by autoplay rules, or the file path is absolute. Start audio from a click handler and use relative paths.

Can an HTML app play music in the background?

No. The WebView pauses when the app leaves the screen. Background playback needs a native media service.

H2

HTML2APK Editorial Team
Written and checked against the app our builder actually produces. Found an error? Tell us.

Turn your HTML into an APK today

Install the free builder on your Android phone, add your HTML file, ZIP or website, and install a signed APK a few minutes later. No watermark, no card.