lairtech
lairtech

Reputation: 2417

Javascript: How to cache small MP3 file for offline play?

I'm building an alarm web app that needs to work offline. How can I cache the small mp3 ringtone so that the alarm still sounds when the app is offline?

Upvotes: 1

Views: 2502

Answers (1)

VoronoiPotato
VoronoiPotato

Reputation: 3183

You can cache using webSQL, indexdb, localstorage, or a cookie. I think using the localstorage would be the simplest solution.

Simple add an appdata.manifest file which has the ringtones you want to store. then in the html tag add

<html lang="en" manifest="appdata.manifest">

the cache file

CACHE MANIFEST
NETWORK: 
/page.html
CACHE:
# v0
# This file will tell the broweser what needs to be Cached
# Spaces are ignored
# Blank Lines are ignored
/music/music.mp3

Upvotes: 2

Related Questions