MP4 Service Worker

Fork me on GitHub
Star Fork Watch

This page demonstrates the use of MP4Box.js as a Service Worker. It has been tested with Google Chrome 45 and Firefox Nightly 44.0a1, make sure you load this page using HTTPS!

By loading this page in Chrome, you have registered a Service Worker for the scope './'. You can check the registration using chrome://serviceworker-internals/ or about:serviceworkers.

service worker registration:

This Service Worker intercepts requests to resources in its scope, checks if the response is an MP4 file. If so, it parses it and determines if there is HTML content in the MP4 file (stored as a primary item in a 'meta' box whose handler is 'html'). If so, the Service Worker forwards first the HTML content to the browser. All further requests made by the browser (because referenced from the HTML page) will be checked by the Service Worker to see if the resource is in the MP4 file. The MP4 file acts as a package for resources associated to the MP4 file.

Example videos: