Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.82 KB

livestream.md

File metadata and controls

59 lines (45 loc) · 1.82 KB

Livestream playback

You need to provide a livestream URL in MediaDataSource and indicates isLive: true.

Sample MPEG2-TS over HTTP source:

{
    // MPEG2-TS over HTTP
    "type": "mpegts",
    "isLive": true,
    "url": "http://127.0.0.1:8080/live/livestream.ts"
}

Sample HTTP FLV source:

{
    // HTTP FLV
    "type": "flv",
    "isLive": true,
    "url": "http://127.0.0.1:8080/live/livestream.flv"
}

Or a WebSocket source:

{
    // MPEG2-TS/FLV over WebSocket
    "type": "mse",
    "isLive": true,
    "url": "ws://127.0.0.1:9090/live/livestream.flv"
}

HTTP MPEG2-TS/FLV live stream

CORS

You must configure Access-Control-Allow-Origin header correctly on your stream server.

See cors.md for details.

Compatibility

Due to IO restrictions, mpegts.js can support HTTP MPEG2-TS/FLV live stream on Chrome 43+, FireFox 42+, Edge 15.15048+ and Safari 10.1+ for now.

HTTP MPEG2-TS/FLV live stream relies on stream IO, which has been introduced in fetch and stream spec. Now FetchStreamLoader works well on most of the modern browsers:

  • Chrome: FetchStreamLoader works well on Chrome 43+
  • FireFox: FireFox has fetch support but stream is missing, moz-chunked-arraybuffer xhr extension is used
  • Edge: fetch + stream is broken on old version of Microsoft Edge, see Fetch API with ReadableStream has bug with data pumping. Got fixed in Creator Update (RS2).
  • Safari: FetchStreamLoader works well since Safari 10.1 (macOS 10.12.4)