NusaPlayer

Install

NusaPlayer is a plugin-based HTML5 player. @nusaplayer/core is the engine. UI, streaming, danmaku, and extras are separate packages you opt into with .use([...]).create().

Packages

PackageRole
@nusaplayer/coreengine, events, Player.make
@nusaplayer/uicontrols, theme, subtitle, screenshot, PiP
@nusaplayer/hlsHLS via hls.js
@nusaplayer/dashDASH via dash.js
@nusaplayer/mpegtsFLV / MPEG-TS via mpegts.js
@nusaplayer/shakaShaka Player
@nusaplayer/torrentWebTorrent
@nusaplayer/danmakudanmaku + sender
@nusaplayer/pluginsplaylist, Chromecast, AirPlay, ads, VTT thumbs
@nusaplayer/reactReact wrapper
@nusaplayer/vueVue 3 wrapper
@nusaplayer/fullone UMD bundle (core + ui + loaders)

UMD globals: NusaPlayer, NusaUI, NusaHls, NusaDash, NusaMpegts, NusaShaka, NusaTorrent, NusaDanmaku.

npm i @nusaplayer/core @nusaplayer/ui @nusaplayer/hls hls.js
app.js
import Player from '@nusaplayer/core'
import ui from '@nusaplayer/ui'
import hls from '@nusaplayer/hls'
 
const player = Player.make('#player', {
  lang: 'en',
  source: {
    title: "Disney's Oceans",
    src: 'https://vjs.zencdn.net/v/oceans.mp4',
    poster: 'https://vjs.zencdn.net/v/oceans.png'
  }
})
  .use([
    ui({
      keyboard: { global: true },
      screenshot: true,
      pictureInPicture: true,
      subtitle: {
        source: [
          { name: 'English', default: true, src: '/demo/en.srt' },
          { name: 'English (styled)', src: '/demo/styled.vtt' },
          { name: 'Indonesia', src: '/demo/id.srt' }
        ]
      }
    }),
    hls({ forceHLS: true })
  ])
  .create()

How plugins attach

Player.make(container, options)
  .use([pluginA, pluginB])
  .create()
  1. make builds the instance (DOM is not mounted yet).
  2. use queues plugins.
  3. create renders the <video>, applies plugins, then loads options.source if src is set.

After create, plugin instances live on player.context using each plugin key:

player.context.ui
player.context.hls
player.context.danmaku
player.context.playlist

Streaming samples

FormatURL
MP4https://vjs.zencdn.net/v/oceans.mp4
HLShttps://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8
DASHhttps://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd
HLS multihttps://storage.googleapis.com/shaka-demo-assets/angel-one-hls/hls.m3u8
DASH multihttps://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd
WebTorrenthttps://webtorrent.io/torrents/sintel.torrent

HLS / DASH / FLV servers must send CORS headers. Safari can play HLS natively; set forceHLS: true if you still want hls.js quality menus.

Develop this repo

pnpm i
pnpm run build
pnpm run dev:exam

Standalone demo: http://localhost:5173/