For some reason, the only mobile browser that will play cached videos is Firefox on Android. However, there is a solution (For Safari iOS8+, Chrome, Firefox - I haven't tested IE) - they will play a video blob in an objectURL even offline!
What you do is this:
- Create an indexedDB
- Look for the stored video(s) in the db
request = transaction.objectStore( "myobjectstorename" ).get( savedId )
- Check the return, if there, move to step 5, otherwise step 4
if ( !event.target.result ) downloadVideo()
- Download the video by running an
XMLHttpRequest
GET
request and set the response type videoRequest.responseType = "blob";
- When it's downloaded, retrieve it from the database (step 2 above) and put it into the document:
CODE To Put in page as object url:
var URL = window.URL || window.webkitURL;
//Make into a data URL
var videoURL = URL.createObjectURL( videoFile) ;
//Set video src to ObjectURL
document.getElementById( id ).setAttribute( "src", videoURL );
Modified the code from here:
http://www.misfitgeek.com/html5-off-line-storing-and-retrieving-videos-with-indexeddb/