1.4.12 • Published 7 months ago

hls.js v1.4.12

Weekly downloads
164,789
License
Apache-2.0
Repository
github
Last release
7 months ago

Build Status npm Greenkeeper badge npm.io

Join the discussion on Slack#hlsjs Slack Status

hls.js

hls.js is a JavaScript library which implements an HTTP Live Streaming client. It relies on HTML5 video and MediaSource Extensions for playback.

It works by transmuxing MPEG-2 Transport Stream and AAC/MP3 streams into ISO BMFF (MP4) fragments. This transmuxing could be performed asynchronously using Web Worker if available in the browser. hls.js also supports HLS + fmp4, as announced during WWDC2016

hls.js does not need any player, it works directly on top of a standard HTML<video>element.

hls.js is written in ECMAScript6, and transpiled in ECMAScript5 using Babel.

API docs and usage guide

Demo

http://video-dev.github.io/hls.js/demo

Getting Started

<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<!-- Or if you want a more recent canary version -->
<!-- <script src="https://cdn.jsdelivr.net/npm/hls.js@canary"></script> -->
<video id="video"></video>
<script>
  var video = document.getElementById('video');
  if(Hls.isSupported()) {
    var hls = new Hls();
    hls.loadSource('https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8');
    hls.attachMedia(video);
    hls.on(Hls.Events.MANIFEST_PARSED,function() {
      video.play();
  });
 }
 // hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
 // When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element throught the `src` property.
 // This is using the built-in support of the plain video element, without using hls.js.
 // Note: it would be more normal to wait on the 'canplay' event below however on Safari (where you are most likely to find built-in HLS support) the video.src URL must be on the user-driven
 // white-list before a 'canplay' event will be emitted; the last video event that can be reliably listened-for when the URL is not on the white-list is 'loadedmetadata'.
  else if (video.canPlayType('application/vnd.apple.mpegurl')) {
    video.src = 'https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8';
    video.addEventListener('loadedmetadata',function() {
      video.play();
    });
  }
</script>

Video Control

Video is controlled through HTML <video> element.

HTMLVideoElement control and events could be used seamlessly.

they use hls.js in production !

Player Integration

hls.js is (being) integrated in the following players:

Chrome/Firefox integration

made by gramk, plays hls from address bar and m3u8 links

Dependencies

No external JS libs are needed. Prepackaged build is included in the dist folder:

If you want to bundle the application yourself, use node

npm install hls.js

or for the version from master (canary)

npm install hls.js@canary

NOTE: hls.light.*.js dist files do not include subtitling and alternate-audio features.

Installation

Either directly include dist/hls.js or dist/hls.min.js

Or type

npm install --save hls.js

Optionally there is a declaration file available to help with code completion and hinting within your IDE for the hls.js api

npm install --save-dev @types/hls.js

Compatibility

hls.js is compatible with browsers supporting MediaSource extensions (MSE) API with 'video/MP4' mimetypes inputs.

Find a support matrix of the MediaSource API here: https://developer.mozilla.org/en-US/docs/Web/API/MediaSource

As of today, it is supported on:

  • Chrome for Android 34+
  • Chrome for Desktop 34+
  • Firefox for Android 41+
  • Firefox for Desktop 42+
  • IE11+ for Windows 8.1+
  • Edge for Windows 10+
  • Opera for Desktop
  • Vivaldi for Desktop
  • Safari for Mac 8+ (beta)

Please note: iOS Safari "Mobile" does not support the MediaSource API. Safari browsers have however built-in HLS support through the plain video "tag" source URL. See the example above (Getting Started) to run appropriate feature detection and choose between using Hls.js or natively built-in HLS support.

When a platform has neither MediaSource nor native HLS support, you will not be able to play HLS.

CORS

All HLS resources must be delivered with CORS headers permitting GET requests.

Features

  • VoD & Live playlists
    • DVR support on Live playlists
  • fragmented MP4 container (beta)
  • MPEG-2 TS container
    • ITU-T Rec. H.264 and ISO/IEC 14496-10 Elementary Stream
    • ISO/IEC 13818-7 ADTS AAC Elementary Stream
    • ISO/IEC 11172-3 / ISO/IEC 13818-3 (MPEG-1/2 Audio Layer III) Elementary Stream
    • Packetized metadata (ID3) Elementary Stream
  • AAC container (audio only streams)
  • MPEG Audio container (MPEG-1/2 Audio Layer III audio only streams)
  • Timed Metadata for HTTP Live Streaming (in ID3 format, carried in MPEG-2 TS)
  • AES-128 decryption
  • SAMPLE-AES decryption (only supported if using MPEG-2 TS container)
  • Encrypted media extensions (EME) support for DRM (digital rights management)
    • Widevine CDM (beta/experimental) (see Shaka-package test-stream in demo)
  • CEA-608/708 captions
  • WebVTT subtitles
  • Alternate Audio Track Rendition (Master Playlist with alternative Audio) for VoD and Live playlists
  • Adaptive streaming
    • Manual & Auto Quality Switching
      • 3 Quality Switching modes are available (controllable through API means) - Instant switching (immediate quality switch at current video position) - Smooth switching (quality switch for next loaded fragment) - Bandwidth conservative switching (quality switch change for next loaded fragment, without flushing the buffer)
      • In Auto-Quality mode, emergency switch down in case bandwidth is suddenly dropping to minimize buffering.
  • Accurate Seeking on VoD & Live (not limited to fragment or keyframe boundary)
  • Ability to seek in buffer and back buffer without redownloading segments
  • Built-in Analytics
    • Every internal events could be monitored (Network Events,Video Events)
    • Playback session metrics are also exposed
  • Resilience to errors
    • Retry mechanism embedded in the library
    • Recovery actions could be triggered fix fatal media or network errors
  • Redundant/Failover Playlists

Not Supported (Yet)

  • MP3 Elementary Stream in Edge for Windows 10+

Supported M3U8 tags

License

hls.js is released under Apache 2.0 License

Contributing

Pull requests are welcome. Here is a quick guide on how to start.

  • First, checkout the repository and install required dependencies
git clone https://github.com/video-dev/hls.js.git
# setup dev environement
cd hls.js
npm install
# build dist/hls.js, watch file change for rebuild and launch demo page
npm run dev
# lint
npm run lint
  • Use EditorConfig or at least stay consistent to the file formats defined in the .editorconfig file.
  • Develop in a topic branch, not master
  • Don't commit the updated dist/hls.js file in your PR. We'll take care of generating an updated build right before releasing a new tagged version.

Design

Click here for details.

Tested With

vue3-nre@amityco/ts-sdk@bbc/storyplayerzaa-t-a-p-v2gdy-editorvue-custom-videom2a-ui-libraryext-video-componentjsn_web2demio-browser-viewervideojs5-hlsjs-source-handlersupremind-componentve-playerahs-videohkvideo-player-hlshk-player-hls@kimpaow/sanity-plugin-mux-inputnete2-player-hlsjp-web-playerxr3-spokexrchat-spokemui-player-glupmsb-coursemsb_coursesc-ui.jssupconui.js@ubaid-desynova/playerbaseplayer@lin-view-ui/video-playersmile-xin-amisfastamisgoplayerreact-daily-widgetssupremind-components@ai-lion/lion-peercfbgc-componentspro-gallery@everything-registry/sub-chunk-1851@kevingodell/node-red-ui-mp4fragdatav-amiswxm-component-libraryskara-playerskara-player-1skara-test-video-playerpro-playerpro-player-v2qy-ui-pluspulsar-hlsjssimple-react-video-player@redshift-ui/react@rtarojs/componentswang-view-ui@samvera/clover-iiif@samvera/nectar-iiif@s-ui/react-atom-video-player@panelist/react-hls-player@odnoklassniki/player-sdkriver-elementroovroov-playerroov-player-v3@rg-npmjs-dev/rg-amity-social-ui@react-av/hls@onehop/client@oiz/stzh-componentsresponsive-image-reactrg-amity-social-uisanity-mux-playersanzhi-low-code-vue3@playkit-js/kaltura-player-js@popcorn-video/hlsjs-decodersanity-plugin-mux-input-privatesanity-plugin-mux-input-v2-fixedsuperdesk-coresupervideo@piscale/chat-react@plaso-infi/whiteboard-sdk@snipfeed/tint@skillrecordings/player@sl-theia/theia-video@neuqsoft/media-player@netology-group/react-hlsreact-pro-playerrahulrsingh09-stenciltest2ppenginxportmachinery-pluginreact-hlsreact-hls-playerreact-hls-videoreact-hlsjsreact-iiif-media-playerreact-video-hls@no-framework/videoplayerreact-xrplayer@nulib/react-media-playerqingplayerqjam-websiteqk-amisqplayreacttoqueplayerhlstream2
1.5.0-alpha.0

8 months ago

1.4.11

8 months ago

1.4.12

8 months ago

1.4.5-0.canary.9207

11 months ago

1.4.5-0.canary.9169

11 months ago

1.4.5-0.canary.9165

11 months ago

1.4.5-0.canary.9167

11 months ago

1.4.5-0.canary.9173

11 months ago

1.4.5-0.canary.9175

11 months ago

1.4.5-0.canary.9171

11 months ago

1.4.5-0.canary.9161

11 months ago

1.4.5-0.canary.9162

11 months ago

1.4.5-0.canary.9163

11 months ago

1.4.5-0.canary.9199

11 months ago

1.4.5-0.canary.9187

11 months ago

1.4.5-0.canary.9189

11 months ago

1.4.5-0.canary.9196

11 months ago

1.4.5-0.canary.9197

11 months ago

1.4.5-0.canary.9191

11 months ago

1.4.5-0.canary.9177

11 months ago

1.4.5-0.canary.9183

11 months ago

1.4.5-0.canary.9185

11 months ago

1.4.5-0.canary.9181

11 months ago

1.4.9-0.canary.9369

10 months ago

1.4.9-0.canary.9368

10 months ago

1.4.9-0.canary.9367

10 months ago

1.4.9-0.canary.9365

10 months ago

1.4.9-0.canary.9364

10 months ago

1.4.9-0.canary.9362

10 months ago

1.4.9-0.canary.9360

10 months ago

1.4.9-0.canary.9356

10 months ago

1.4.9-0.canary.9354

10 months ago

1.4.9-0.canary.9352

10 months ago

1.4.9-0.canary.9350

10 months ago

1.4.4-0.canary.9156

12 months ago

1.4.4-0.canary.9157

11 months ago

1.4.4-0.canary.9158

11 months ago

1.4.4-0.canary.9159

11 months ago

1.4.4-0.canary.9160

11 months ago

1.4.9-0.canary.9348

10 months ago

1.4.9-0.canary.9346

10 months ago

1.4.9-0.canary.9345

10 months ago

1.4.9-0.canary.9343

10 months ago

1.4.9-0.canary.9341

10 months ago

1.4.9-0.canary.9339

10 months ago

1.4.9-0.canary.9337

10 months ago

1.4.9-0.canary.9335

10 months ago

1.4.9-0.canary.9333

10 months ago

1.4.9-0.canary.9330

10 months ago

1.4.9-0.canary.9328

10 months ago

1.4.10

9 months ago

1.4.6

11 months ago

1.4.5

11 months ago

1.4.4

11 months ago

1.4.9

10 months ago

1.4.8

10 months ago

1.4.7

10 months ago

1.4.5-0.canary.9312

10 months ago

1.4.5-0.canary.9314

10 months ago

1.4.5-0.canary.9310

10 months ago

1.4.5-0.canary.9306

10 months ago

1.4.5-0.canary.9308

10 months ago

1.4.5-0.canary.9302

10 months ago

1.4.5-0.canary.9304

10 months ago

1.4.5-0.canary.9300

10 months ago

1.4.5-0.canary.9286

10 months ago

1.4.5-0.canary.9288

10 months ago

1.4.5-0.canary.9294

10 months ago

1.4.5-0.canary.9296

10 months ago

1.4.5-0.canary.9290

10 months ago

1.4.5-0.canary.9292

10 months ago

1.4.5-0.canary.9276

10 months ago

1.4.5-0.canary.9278

10 months ago

1.4.5-0.canary.9282

10 months ago

1.4.5-0.canary.9284

10 months ago

1.4.5-0.canary.9280

10 months ago

1.4.5-0.canary.9268

11 months ago

1.4.5-0.canary.9264

11 months ago

1.4.5-0.canary.9266

11 months ago

1.4.5-0.canary.9272

10 months ago

1.4.5-0.canary.9274

10 months ago

1.4.5-0.canary.9270

10 months ago

1.4.5-0.canary.9257

11 months ago

1.4.5-0.canary.9259

11 months ago

1.4.5-0.canary.9253

11 months ago

1.4.5-0.canary.9255

11 months ago

1.4.5-0.canary.9261

11 months ago

1.4.5-0.canary.9262

11 months ago

1.4.5-0.canary.9247

11 months ago

1.4.5-0.canary.9249

11 months ago

1.4.5-0.canary.9243

11 months ago

1.4.5-0.canary.9245

11 months ago

1.4.5-0.canary.9251

11 months ago

1.4.5-0.canary.9236

11 months ago

1.4.5-0.canary.9238

11 months ago

1.4.5-0.canary.9232

11 months ago

1.4.5-0.canary.9234

11 months ago

1.4.5-0.canary.9241

11 months ago

1.4.5-0.canary.9228

11 months ago

1.4.5-0.canary.9224

11 months ago

1.4.5-0.canary.9226

11 months ago

1.4.5-0.canary.9220

11 months ago

1.4.5-0.canary.9222

11 months ago

1.4.5-0.canary.9230

11 months ago

1.4.5-0.canary.9218

11 months ago

1.4.5-0.canary.9214

11 months ago

1.4.5-0.canary.9216

11 months ago

1.4.5-0.canary.9210

11 months ago

1.4.5-0.canary.9212

11 months ago

1.4.5-0.canary.9298

10 months ago

1.4.2-0.canary.9153

12 months ago

1.4.2-0.canary.9152

12 months ago

1.4.2-0.canary.9150

12 months ago

1.4.2-0.canary.9148

12 months ago

1.4.2-0.canary.9146

12 months ago

1.4.2-0.canary.9145

12 months ago

1.4.2-0.canary.9144

12 months ago

1.4.2-0.canary.9142

12 months ago

1.4.2-0.canary.9140

12 months ago

1.4.2-0.canary.9138

12 months ago

1.4.2-0.canary.9136

12 months ago

1.4.2-0.canary.9134

12 months ago

1.4.2-0.canary.9132

12 months ago

1.4.2-0.canary.9130

12 months ago

1.4.2-0.canary.9128

12 months ago

1.4.1-0.canary.9124

12 months ago

1.4.1-0.canary.9121

12 months ago

1.4.1-0.canary.9122

12 months ago

1.4.1-0.canary.9116

12 months ago

1.4.1-0.canary.9114

12 months ago

1.4.1-0.canary.9118

12 months ago

1.4.1-0.canary.9119

12 months ago

1.4.1-0.canary.9126

12 months ago

1.4.1-0.canary.9112

12 months ago

1.4.1-0.canary.9110

12 months ago

1.4.1-0.canary.9111

12 months ago

1.4.3-0.canary.9155

12 months ago

1.4.3-0.canary.9154

12 months ago

1.4.3

12 months ago

1.4.2

12 months ago

1.4.1

12 months ago

1.4.0

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.4.0-beta.2

1 year ago

1.4.0-beta.1

1 year ago

1.4.0-rc.1

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.3.0-beta.1

1 year ago

1.3.0-beta.2

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.9

1 year ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0-beta.1

2 years ago

1.2.0-beta.2

2 years ago

1.2.0

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.11-beta.1

3 years ago

1.0.10

3 years ago

1.0.9-alpha.7

3 years ago

1.0.9

3 years ago

1.0.9-alpha.6

3 years ago

1.0.9-alpha.4

3 years ago

1.0.9-alpha.3

3 years ago

1.0.9-alpha.2

3 years ago

1.0.9-alpha.1

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-rc.6

3 years ago

1.0.0-rc.5

3 years ago

1.0.0-rc.4

3 years ago

1.0.0-rc.3

3 years ago

1.0.0-rc.2

3 years ago

1.0.0-rc.1

3 years ago

1.0.0-beta.6

3 years ago

1.0.0-beta.5

3 years ago

1.0.0-beta.4

3 years ago

1.0.0-beta.3

3 years ago

1.0.0-beta.2

3 years ago

1.0.0-beta.1

3 years ago

1.0.0-alpha.5

3 years ago

1.0.0-alpha.4

3 years ago

0.14.17

3 years ago

1.0.0-alpha.3

3 years ago

1.0.0-alpha.2

3 years ago

0.15.0-alpha.2

3 years ago

0.14.16

4 years ago

0.14.15

4 years ago

0.14.14

4 years ago

1.0.0-alpha.1

4 years ago

0.14.13

4 years ago

0.14.12

4 years ago

0.14.11

4 years ago

0.14.10

4 years ago

0.14.9

4 years ago

0.14.8

4 years ago

0.14.7

4 years ago

0.14.6

4 years ago

0.14.5

4 years ago

0.14.4

4 years ago

0.14.3

4 years ago

0.14.2

4 years ago

0.14.1

4 years ago

0.14.0

4 years ago

0.14.0-rc.2

4 years ago

0.14.0-rc.1

4 years ago

0.14.0-beta.2

4 years ago

0.14.0-beta.1

4 years ago

0.13.2

4 years ago

0.13.1

4 years ago

0.13.0

4 years ago

0.13.0-beta.3

4 years ago

0.13.0-beta.2

4 years ago

0.13.0-beta.1

5 years ago

0.12.5-beta.2

5 years ago

0.12.5-beta.1

5 years ago

0.12.4

5 years ago

0.12.3

5 years ago

0.12.2

5 years ago

0.12.1

5 years ago

0.12.0

5 years ago

0.11.0

6 years ago

0.10.1

6 years ago

0.10.0

6 years ago

0.9.2-canary.303

6 years ago

0.9.2-canary.324

6 years ago

0.9.2-canary.348

6 years ago

0.9.1

6 years ago

0.9.0

6 years ago

0.8.9

6 years ago

0.8.8

6 years ago

0.8.7

6 years ago

0.8.6

6 years ago

0.8.5

7 years ago

0.8.4

7 years ago

0.8.3

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.8.0

7 years ago

0.7.11

7 years ago

0.7.10

7 years ago

0.7.9

7 years ago

0.7.8

7 years ago

0.7.7

7 years ago

0.7.6

7 years ago

0.7.5

7 years ago

0.7.4

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.21

7 years ago

0.6.20

7 years ago

0.6.19

7 years ago

0.6.18

7 years ago

0.6.17

7 years ago

0.6.16

7 years ago

0.6.15

7 years ago

0.6.14

7 years ago

0.6.13

7 years ago

0.6.12

7 years ago

0.6.11

7 years ago

0.6.10

7 years ago

0.6.9

7 years ago

0.5.52

7 years ago

0.6.8

7 years ago

0.6.7

8 years ago

0.6.6

8 years ago

0.5.51

8 years ago

0.5.50

8 years ago

0.6.5

8 years ago

0.6.4

8 years ago

0.6.3

8 years ago

0.6.2

8 years ago

0.5.49

8 years ago

0.6.2-7

8 years ago

0.5.48

8 years ago

0.5.47

8 years ago

0.6.2-6

8 years ago

0.6.2-5

8 years ago

0.5.46

8 years ago

0.5.45

8 years ago

0.6.2-4

8 years ago

0.5.44

8 years ago

0.5.43

8 years ago

0.5.42

8 years ago

0.6.2-3

8 years ago

0.6.2-2

8 years ago

0.6.2-1

8 years ago

0.6.2-0

8 years ago

0.5.41

8 years ago

0.5.40

8 years ago

0.5.39

8 years ago

0.5.38

8 years ago

0.5.37

8 years ago

0.5.36

8 years ago

0.5.35

8 years ago

0.5.34

8 years ago

0.5.33

8 years ago

0.5.32

8 years ago

0.5.31

8 years ago

0.5.30

8 years ago

0.5.29

8 years ago

0.5.28

8 years ago

0.5.27

8 years ago

0.5.26

8 years ago

0.5.25

8 years ago

0.5.24

8 years ago

0.5.23

8 years ago

0.5.22

8 years ago

0.5.21

8 years ago

0.5.20

8 years ago

0.6.1

8 years ago

0.5.19

8 years ago

0.5.18

8 years ago

0.5.17

8 years ago

0.5.16

8 years ago

0.6.0

8 years ago

0.5.15

8 years ago

0.5.14

8 years ago

0.5.13

8 years ago

0.5.12

8 years ago

0.5.11

8 years ago

0.5.10

8 years ago

0.5.9

8 years ago

0.5.8

8 years ago

0.5.7

8 years ago

0.5.6

8 years ago

0.5.5

8 years ago

0.5.4

8 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.4

8 years ago

0.4.0

8 years ago