swarm-video-viewer
Version:
Swarm video viewer for any player
50 lines (35 loc) • 1.22 kB
Markdown
`swarm-video-viewer` bridges the core engine with [hls.js](https://github.com/video-dev/hls.js). It supplies a custom loader class so the player can fetch HLS segments from peers.
Install the package from npm:
```bash
npm install swarm-video-viewer
```
The package ships with a prebuilt `dist/index.iife.js` bundle. Most users can skip the build step; run it only when you need a custom version:
```bash
pnpm build:iife
```
Include the prebuilt script directly from jsDelivr:
```html
<script src="https://cdn.jsdelivr.net/npm/swarm-video-viewer/dist/index.iife.js"></script>
```
```html
<script>
const { Engine, initHlsJsPlayer } = swarmViewer
const engine = new Engine()
const hls = new Hls({ loader: engine.createLoaderClass() })
initHlsJsPlayer(hls)
</script>
```
```javascript
import Hls from 'hls.js'
import { Engine } from 'swarm.video-core'
import { initHlsJsPlayer } from 'swarm-video-viewer'
const engine = new Engine()
const hls = new Hls({ loader: engine.createLoaderClass() })
initHlsJsPlayer(hls)
```
More configuration options are available in the main project README.
Try the live demo at [swarm.video](https://swarm.video).