# Background Audio Playback

> Keep playing when the user leaves the app or turns the screen off.

- **Applies to:** AppMint and Appwright
- **Source:** the Integration Guide shipped inside the app; this page is generated from it.
- **HTML:** https://freewebtoapk.com/docs/background-audio

Keep Audio Playing When Minimized

### 1. What is Background Audio?

When enabled, audio/music playing in your WebView will continue playing even when the user switches to another app or turns off the screen.

Perfect for:

- Music streaming websites (SoundCloud, Bandcamp)
- Podcast platforms
- Radio stations
- Audio meditation / prayer apps
- YouTube music channels

### 2. Enable in Generator

In Step 2 (Display Settings):

1. Scroll to 'Display Options'
2. Toggle ON 'Background Audio Playback'
3. Generate your APK

No code changes needed on your website.

### 3. How It Works

Normally, when an Android app goes to the background, its WebView pauses all media playback. With Background Audio enabled:

- WebView is NOT paused when app goes to background
- Audio continues playing via the device speaker or headphones
- Video playback also continues (audio portion)

💡 Tip: Combine with PiP for video sites so users can watch in a floating window AND keep audio when the window is dismissed.

### 4. Battery Considerations

⚠️ Background audio keeps the WebView process alive, which uses more battery.

✅ Recommended: Only enable for apps that genuinely need background audio

✅ Users can still stop playback by pausing on your website or force-stopping the app

✅ Android's battery optimization may eventually pause background apps - this is normal system behavior.

### 5. Website Best Practices

For the best background audio experience, ensure your website:

✅ Uses the HTML5 <audio> or <video> elements  
✅ Has play/pause controls easily accessible  
✅ Handles the 'visibilitychange' event gracefully  
✅ Does not auto-pause media when the page loses focus

```
// Prevent auto-pause on visibility change:
document.addEventListener('visibilitychange', function() {
  // Don't pause audio when tab/app is hidden
  if (document.hidden) {
    // Keep playing - do nothing
  }
});
```

