Skip to main content

Introduction

npmjsdelivr

This MP4/MP3 SDK creates a communal, distributed CDN with the latest HTML5 APIs — WebRTC to connect browsers, ServiceWorker to fulfill requests. As you might expect, it supports all modern browsers and all web players.

Browser Support

WebRTC has already been incorporated into the HTML5 standard and it is broadly deployed in modern browsers. The compatibility of SwarmCloud depends on the browser support of WebRTC and Service Worker.

CompatibilityChromeFirefoxmacOS SafariOperaEdgeiOS SafariIE
WebRTC Datachannel
Service Worker
Supported

How does it Work?

  • The SwarmCloud SDK embeds a local proxy server between the player and the origin to intercept content requests
  • The player starts streaming content through the proxy.
  • The local proxy(ServiceWorker) waits for network requests of MP4/MP3 by listening for network fetch events, then forward the request to main thread
self.addEventListener('fetch', event => { /* ⛦ magic here ⛦ */ })
  • The main thread decides whether to download from the peer according to the P2P network situation. After downloading, the main thread save a copy to share with other nodes
  • After an asset is cached, every device watches for future requests for that asset and automatically retrieves it from peer-to-peer network instead of the more expensive, slower origin server (over WebRTC instead of HTTP).
  • If no peers or p2p failed, the request fall through Service Worker unmodified and are fetched from the origin server

Limitations

  • Only work on https website
  • Need to host our web SDK(sw.js) on your own servers instead of getting it from our public cloud

Demo

Click me!