Offline storage of mp3 files on Android in a progressive web app

3.5k Views Asked by At

I'm building an app that needs to allow users to download mp3 files to the phone and play the files locally. I'm trying to decide whether a progressive web app (pwa) can handle this use case or whether I need to build a traditional native app for that.

My main concerns about pwa are

  1. whether it'd support downloading large media files. The app would need up to 10 mb storage for audio files alone, not to mention caching the app itself for offline usage.

  2. whether background playing mode for a pwa is supported on Android.

Does anybody know the answers to these questions?

1

There are 1 best solutions below

0
abielita On

You may check this article about Offline Storage for Progressive Web Apps. Offline support and reliable performance are common features in Progressive Web Apps.

For URL addressable resources, use the Cache API (part of Service Worker). For all other data, use IndexedDB (with a Promises wrapper).

You can also check this blog: Progressive Web Apps with Service Workers

The ServiceWorker API provides very granular methods for developers to intercept requests, to cache and forge responses, opening doors for all kinds of interesting activities like:

  • Offline access to certain pages
  • Precaching assets based on predictions of next user actions
  • Serving a cached version when it takes too long to load some resources
  • Rewriting URLs to always be requested with a canonical url