@zenvor/hls.js 1.6.15-fork.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +472 -0
  3. package/dist/hls-demo.js +25686 -0
  4. package/dist/hls-demo.js.map +1 -0
  5. package/dist/hls.d.mts +4204 -0
  6. package/dist/hls.d.ts +4204 -0
  7. package/dist/hls.js +40038 -0
  8. package/dist/hls.js.d.ts +4204 -0
  9. package/dist/hls.js.map +1 -0
  10. package/dist/hls.light.js +27133 -0
  11. package/dist/hls.light.js.map +1 -0
  12. package/dist/hls.light.min.js +2 -0
  13. package/dist/hls.light.min.js.map +1 -0
  14. package/dist/hls.light.mjs +26382 -0
  15. package/dist/hls.light.mjs.map +1 -0
  16. package/dist/hls.min.js +2 -0
  17. package/dist/hls.min.js.map +1 -0
  18. package/dist/hls.mjs +38946 -0
  19. package/dist/hls.mjs.map +1 -0
  20. package/dist/hls.worker.js +2 -0
  21. package/dist/hls.worker.js.map +1 -0
  22. package/package.json +143 -0
  23. package/src/config.ts +794 -0
  24. package/src/controller/abr-controller.ts +1019 -0
  25. package/src/controller/algo-data-controller.ts +782 -0
  26. package/src/controller/audio-stream-controller.ts +1099 -0
  27. package/src/controller/audio-track-controller.ts +454 -0
  28. package/src/controller/base-playlist-controller.ts +438 -0
  29. package/src/controller/base-stream-controller.ts +2526 -0
  30. package/src/controller/buffer-controller.ts +2015 -0
  31. package/src/controller/buffer-operation-queue.ts +159 -0
  32. package/src/controller/cap-level-controller.ts +367 -0
  33. package/src/controller/cmcd-controller.ts +422 -0
  34. package/src/controller/content-steering-controller.ts +622 -0
  35. package/src/controller/eme-controller.ts +1617 -0
  36. package/src/controller/error-controller.ts +627 -0
  37. package/src/controller/fps-controller.ts +146 -0
  38. package/src/controller/fragment-finders.ts +256 -0
  39. package/src/controller/fragment-tracker.ts +567 -0
  40. package/src/controller/gap-controller.ts +719 -0
  41. package/src/controller/id3-track-controller.ts +488 -0
  42. package/src/controller/interstitial-player.ts +302 -0
  43. package/src/controller/interstitials-controller.ts +2895 -0
  44. package/src/controller/interstitials-schedule.ts +698 -0
  45. package/src/controller/latency-controller.ts +294 -0
  46. package/src/controller/level-controller.ts +776 -0
  47. package/src/controller/stream-controller.ts +1597 -0
  48. package/src/controller/subtitle-stream-controller.ts +508 -0
  49. package/src/controller/subtitle-track-controller.ts +617 -0
  50. package/src/controller/timeline-controller.ts +677 -0
  51. package/src/crypt/aes-crypto.ts +36 -0
  52. package/src/crypt/aes-decryptor.ts +339 -0
  53. package/src/crypt/decrypter-aes-mode.ts +4 -0
  54. package/src/crypt/decrypter.ts +225 -0
  55. package/src/crypt/fast-aes-key.ts +39 -0
  56. package/src/define-plugin.d.ts +17 -0
  57. package/src/demux/audio/aacdemuxer.ts +126 -0
  58. package/src/demux/audio/ac3-demuxer.ts +170 -0
  59. package/src/demux/audio/adts.ts +249 -0
  60. package/src/demux/audio/base-audio-demuxer.ts +205 -0
  61. package/src/demux/audio/dolby.ts +21 -0
  62. package/src/demux/audio/mp3demuxer.ts +85 -0
  63. package/src/demux/audio/mpegaudio.ts +177 -0
  64. package/src/demux/chunk-cache.ts +42 -0
  65. package/src/demux/dummy-demuxed-track.ts +13 -0
  66. package/src/demux/inject-worker.ts +75 -0
  67. package/src/demux/mp4demuxer.ts +234 -0
  68. package/src/demux/sample-aes.ts +198 -0
  69. package/src/demux/transmuxer-interface.ts +449 -0
  70. package/src/demux/transmuxer-worker.ts +221 -0
  71. package/src/demux/transmuxer.ts +560 -0
  72. package/src/demux/tsdemuxer.ts +1256 -0
  73. package/src/demux/video/avc-video-parser.ts +401 -0
  74. package/src/demux/video/base-video-parser.ts +198 -0
  75. package/src/demux/video/exp-golomb.ts +153 -0
  76. package/src/demux/video/hevc-video-parser.ts +736 -0
  77. package/src/empty-es.js +5 -0
  78. package/src/empty.js +3 -0
  79. package/src/errors.ts +107 -0
  80. package/src/events.ts +548 -0
  81. package/src/exports-default.ts +3 -0
  82. package/src/exports-named.ts +81 -0
  83. package/src/hls.ts +1613 -0
  84. package/src/is-supported.ts +54 -0
  85. package/src/loader/date-range.ts +207 -0
  86. package/src/loader/fragment-loader.ts +403 -0
  87. package/src/loader/fragment.ts +487 -0
  88. package/src/loader/interstitial-asset-list.ts +162 -0
  89. package/src/loader/interstitial-event.ts +337 -0
  90. package/src/loader/key-loader.ts +439 -0
  91. package/src/loader/level-details.ts +203 -0
  92. package/src/loader/level-key.ts +259 -0
  93. package/src/loader/load-stats.ts +17 -0
  94. package/src/loader/m3u8-parser.ts +1072 -0
  95. package/src/loader/playlist-loader.ts +839 -0
  96. package/src/polyfills/number.ts +15 -0
  97. package/src/remux/aac-helper.ts +81 -0
  98. package/src/remux/mp4-generator.ts +1380 -0
  99. package/src/remux/mp4-remuxer.ts +1261 -0
  100. package/src/remux/passthrough-remuxer.ts +434 -0
  101. package/src/task-loop.ts +130 -0
  102. package/src/types/algo.ts +44 -0
  103. package/src/types/buffer.ts +105 -0
  104. package/src/types/component-api.ts +20 -0
  105. package/src/types/demuxer.ts +208 -0
  106. package/src/types/events.ts +574 -0
  107. package/src/types/fragment-tracker.ts +23 -0
  108. package/src/types/level.ts +268 -0
  109. package/src/types/loader.ts +198 -0
  110. package/src/types/media-playlist.ts +92 -0
  111. package/src/types/network-details.ts +3 -0
  112. package/src/types/remuxer.ts +104 -0
  113. package/src/types/track.ts +12 -0
  114. package/src/types/transmuxer.ts +46 -0
  115. package/src/types/tuples.ts +6 -0
  116. package/src/types/vtt.ts +11 -0
  117. package/src/utils/arrays.ts +22 -0
  118. package/src/utils/attr-list.ts +192 -0
  119. package/src/utils/binary-search.ts +46 -0
  120. package/src/utils/buffer-helper.ts +173 -0
  121. package/src/utils/cea-608-parser.ts +1413 -0
  122. package/src/utils/chunker.ts +41 -0
  123. package/src/utils/codecs.ts +314 -0
  124. package/src/utils/cues.ts +96 -0
  125. package/src/utils/discontinuities.ts +174 -0
  126. package/src/utils/encryption-methods-util.ts +21 -0
  127. package/src/utils/error-helper.ts +95 -0
  128. package/src/utils/event-listener-helper.ts +16 -0
  129. package/src/utils/ewma-bandwidth-estimator.ts +97 -0
  130. package/src/utils/ewma.ts +43 -0
  131. package/src/utils/fetch-loader.ts +331 -0
  132. package/src/utils/global.ts +2 -0
  133. package/src/utils/hash.ts +10 -0
  134. package/src/utils/hdr.ts +67 -0
  135. package/src/utils/hex.ts +32 -0
  136. package/src/utils/imsc1-ttml-parser.ts +261 -0
  137. package/src/utils/keysystem-util.ts +45 -0
  138. package/src/utils/level-helper.ts +629 -0
  139. package/src/utils/logger.ts +120 -0
  140. package/src/utils/media-option-attributes.ts +49 -0
  141. package/src/utils/mediacapabilities-helper.ts +301 -0
  142. package/src/utils/mediakeys-helper.ts +210 -0
  143. package/src/utils/mediasource-helper.ts +37 -0
  144. package/src/utils/mp4-tools.ts +1473 -0
  145. package/src/utils/number.ts +3 -0
  146. package/src/utils/numeric-encoding-utils.ts +26 -0
  147. package/src/utils/output-filter.ts +46 -0
  148. package/src/utils/rendition-helper.ts +505 -0
  149. package/src/utils/safe-json-stringify.ts +22 -0
  150. package/src/utils/texttrack-utils.ts +164 -0
  151. package/src/utils/time-ranges.ts +17 -0
  152. package/src/utils/timescale-conversion.ts +46 -0
  153. package/src/utils/utf8-utils.ts +18 -0
  154. package/src/utils/variable-substitution.ts +105 -0
  155. package/src/utils/vttcue.ts +384 -0
  156. package/src/utils/vttparser.ts +497 -0
  157. package/src/utils/webvtt-parser.ts +166 -0
  158. package/src/utils/xhr-loader.ts +337 -0
  159. package/src/version.ts +1 -0
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Copyright (c) 2017 Dailymotion (http://www.dailymotion.com)
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ src/remux/mp4-generator.js and src/demux/exp-golomb.ts implementation in this project
16
+ are derived from the HLS library for video.js (https://github.com/videojs/videojs-contrib-hls)
17
+
18
+ That work is also covered by the Apache 2 License, following copyright:
19
+ Copyright (c) 2013-2015 Brightcove
20
+
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,472 @@
1
+ [![npm](https://img.shields.io/npm/v/hls.js.svg?style=flat)](https://npmjs.org/package/hls.js)
2
+ [![npm](https://img.shields.io/npm/v/hls.js/canary.svg?style=flat)](https://www.npmjs.com/package/hls.js/v/canary)
3
+ [![](https://data.jsdelivr.com/v1/package/npm/hls.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/hls.js)
4
+ [![Sauce Test Status](https://saucelabs.com/buildstatus/robwalch)](https://app.saucelabs.com/u/robwalch)
5
+ [![jsDeliver](https://data.jsdelivr.com/v1/package/npm/hls.js/badge)](https://www.jsdelivr.com/package/npm/hls.js)
6
+
7
+ [comment]: <> ([![Sauce Test Status]&#40;https://saucelabs.com/browser-matrix/robwalch.svg&#41;]&#40;https://saucelabs.com/u/robwalch&#41;)
8
+
9
+ # ![HLS.js](https://raw.githubusercontent.com/video-dev/hls.js/master/docs/logo.svg)
10
+
11
+ HLS.js is a JavaScript library that implements an [HTTP Live Streaming] client.
12
+ It relies on [HTML5 video][] and [MediaSource Extensions][] for playback.
13
+
14
+ It works by transmuxing MPEG-2 Transport Stream and AAC/MP3 streams into ISO BMFF (MP4) fragments.
15
+ Transmuxing is performed asynchronously using a [Web Worker] when available in the browser.
16
+ HLS.js also supports HLS + fmp4, as announced during [WWDC2016](https://developer.apple.com/videos/play/wwdc2016/504/).
17
+
18
+ HLS.js works directly on top of a standard HTML`<video>` element.
19
+
20
+ HLS.js is written in [ECMAScript6] (`*.js`) and [TypeScript] (`*.ts`) (strongly typed superset of ES6), and transpiled in ECMAScript5 using [Babel](https://babeljs.io/) and the [TypeScript compiler].
21
+
22
+ [Rollup] is used to build the distro bundle and serve the local development environment.
23
+
24
+ [html5 video]: https://www.html5rocks.com/en/tutorials/video/basics/
25
+ [mediasource extensions]: https://w3c.github.io/media-source/
26
+ [http live streaming]: https://en.wikipedia.org/wiki/HTTP_Live_Streaming
27
+ [web worker]: https://caniuse.com/#search=worker
28
+ [ecmascript6]: https://github.com/ericdouglas/ES6-Learning#articles--tutorials
29
+ [typescript]: https://www.typescriptlang.org/
30
+ [typescript compiler]: https://www.typescriptlang.org/docs/handbook/compiler-options.html
31
+ [rollup]: https://rollupjs.org/
32
+
33
+ ## Features
34
+
35
+ - VOD & Live playlists
36
+ - DVR support on Live playlists
37
+ - Fragmented MP4 container
38
+ - MPEG-2 TS container
39
+ - ITU-T Rec. H.264 and ISO/IEC 14496-10 Elementary Stream
40
+ - ITU-T Rec. H.265 and ISO/IEC 23008-2 Elementary Stream
41
+ - ISO/IEC 13818-7 ADTS AAC Elementary Stream
42
+ - ISO/IEC 11172-3 / ISO/IEC 13818-3 (MPEG-1/2 Audio Layer III) Elementary Stream
43
+ - ATSC A/52 / AC-3 / Dolby Digital Elementary Stream
44
+ - Packetized metadata (ID3v2.3.0) Elementary Stream
45
+ - AAC container (audio only streams)
46
+ - MPEG Audio container (MPEG-1/2 Audio Layer III audio only streams)
47
+ - Timed Metadata for HTTP Live Streaming (ID3 format carried in MPEG-2 TS, Emsg in CMAF/Fragmented MP4, and DATERANGE playlist tags)
48
+ - AES-128 decryption
49
+ - "identity" format SAMPLE-AES decryption of MPEG-2 TS segments only
50
+ - Encrypted media extensions (EME) support for DRM (digital rights management)
51
+ - FairPlay, PlayReady, Widevine CDMs with fmp4 segments
52
+ - Level capping based on HTMLMediaElement resolution, dropped-frames, and HDCP-Level
53
+ - CEA-608/708 captions
54
+ - WebVTT subtitles
55
+ - Alternate Audio Track Rendition (Master Playlist with Alternative Audio) for VoD and Live playlists
56
+ - Adaptive streaming
57
+ - Manual & Auto Quality Switching
58
+ - 3 Quality Switching modes are available (controllable through API means)
59
+ - Instant switching (immediate quality switch at current video position)
60
+ - Smooth switching (quality switch for next loaded fragment)
61
+ - Bandwidth conservative switching (quality switch change for next loaded fragment, without flushing the buffer)
62
+ - In Auto-Quality mode, emergency switch down in case bandwidth is suddenly dropping to minimize buffering.
63
+ - Accurate Seeking on VoD & Live (not limited to fragment or keyframe boundary)
64
+ - Ability to seek in buffer and back buffer without redownloading segments
65
+ - Built-in Analytics
66
+ - All internal events can be monitored (Network Events, Video Events)
67
+ - Playback session metrics are also exposed
68
+ - Resilience to errors
69
+ - Retry mechanism embedded in the library
70
+ - Recovery actions can be triggered fix fatal media or network errors
71
+ - [Redundant/Failover Playlists](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/UsingHTTPLiveStreaming/UsingHTTPLiveStreaming.html#//apple_ref/doc/uid/TP40008332-CH102-SW22)
72
+ - HLS Variable Substitution
73
+
74
+ ### Supported HLS tags
75
+
76
+ For details on the HLS format and these tags' meanings, see https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis
77
+
78
+ #### Multivariant Playlist tags
79
+
80
+ - `#EXT-X-STREAM-INF:<attribute-list>`
81
+ `<URI>`
82
+ - `#EXT-X-MEDIA:<attribute-list>`
83
+ - `#EXT-X-SESSION-DATA:<attribute-list>`
84
+ - `#EXT-X-SESSION-KEY:<attribute-list>` EME Key-System selection and preloading
85
+ - `#EXT-X-START:TIME-OFFSET=<n>`
86
+ - `#EXT-X-CONTENT-STEERING:<attribute-list>` Content Steering
87
+ - `#EXT-X-DEFINE:<attribute-list>` Variable Substitution (`NAME,VALUE,QUERYPARAM` attributes)
88
+
89
+ #### Media Playlist tags
90
+
91
+ - `#EXTM3U` (ignored)
92
+ - `#EXT-X-INDEPENDENT-SEGMENTS` (ignored)
93
+ - `#EXT-X-VERSION=<n>` (value is ignored)
94
+ - `#EXTINF:<duration>,[<title>]`
95
+ - `#EXT-X-ENDLIST`
96
+ - `#EXT-X-MEDIA-SEQUENCE=<n>`
97
+ - `#EXT-X-TARGETDURATION=<n>`
98
+ - `#EXT-X-DISCONTINUITY`
99
+ - `#EXT-X-DISCONTINUITY-SEQUENCE=<n>`
100
+ - `#EXT-X-BITRATE`
101
+ - `#EXT-X-BYTERANGE=<n>[@<o>]`
102
+ - `#EXT-X-MAP:<attribute-list>`
103
+ - `#EXT-X-KEY:<attribute-list>` (`KEYFORMAT="identity",METHOD=SAMPLE-AES` is only supports with MPEG-2 TS segments)
104
+ - `#EXT-X-PROGRAM-DATE-TIME:<attribute-list>`
105
+ - `#EXT-X-START:TIME-OFFSET=<n>`
106
+ - `#EXT-X-SERVER-CONTROL:<attribute-list>`
107
+ - `#EXT-X-PART-INF:PART-TARGET=<n>`
108
+ - `#EXT-X-PART:<attribute-list>`
109
+ - `#EXT-X-SKIP:<attribute-list>` Delta Playlists
110
+ - `#EXT-X-RENDITION-REPORT:<attribute-list>`
111
+ - `#EXT-X-DATERANGE:<attribute-list>` Metadata
112
+ - HLS EXT-X-DATERANGE Schema for Interstitials
113
+ - `#EXT-X-DEFINE:<attribute-list>` Variable Import and Substitution (`NAME,VALUE,IMPORT,QUERYPARAM` attributes)
114
+ - `#EXT-X-GAP` (Skips loading GAP segments and parts. Skips playback of unbuffered program containing only GAP content and no suitable alternates. See [#2940](https://github.com/video-dev/hls.js/issues/2940))
115
+
116
+ Parsed but missing feature support:
117
+
118
+ - `#EXT-X-PRELOAD-HINT:<attribute-list>` (See [#5074](https://github.com/video-dev/hls.js/issues/3988))
119
+ - #5074
120
+
121
+ ### Not Supported
122
+
123
+ For a complete list of issues, see ["Top priorities" in the Release Planning and Backlog project tab](https://github.com/video-dev/hls.js/projects/6). Codec support is dependent on the runtime environment (for example, not all browsers on the same OS support HEVC).
124
+
125
+ - `#EXT-X-I-FRAME-STREAM-INF` I-frame Media Playlist files
126
+ - `REQ-VIDEO-LAYOUT` is not used in variant filtering or selection
127
+ - "identity" format `SAMPLE-AES` method keys with fmp4, aac, mp3, vtt... segments (MPEG-2 TS only)
128
+ - MPEG-2 TS segments with FairPlay Streaming, PlayReady, or Widevine encryption
129
+ - FairPlay Streaming legacy keys (For com.apple.fps.1_0 use native Safari playback)
130
+ - MP3 elementary stream audio in IE and Edge (<=18) on Windows 10 (See [#1641](https://github.com/video-dev/hls.js/issues/1641) and [Microsoft answers forum](https://answers.microsoft.com/en-us/ie/forum/all/ie11-on-windows-10-cannot-play-hls-with-mp3/2da994b5-8dec-4ae9-9201-7d138ede49d9))
131
+
132
+ ### Server-side-rendering (SSR) and `require` from a Node.js runtime
133
+
134
+ You can safely require this library in Node and **absolutely nothing will happen**. A dummy object is exported so that requiring the library does not throw an error. HLS.js is not instantiable in Node.js. See [#1841](https://github.com/video-dev/hls.js/pull/1841) for more details.
135
+
136
+ ## Getting started with development
137
+
138
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/video-dev/hls.js/tree/master?title=HLS.JS)
139
+
140
+ First, checkout the repository and install the required dependencies
141
+
142
+ ```sh
143
+ git clone https://github.com/video-dev/hls.js.git
144
+ cd hls.js
145
+ # After cloning or pulling from the repository, make sure all dependencies are up-to-date
146
+ npm install ci
147
+ # Run dev-server for demo page (recompiles on file-watch, but doesn't write to actual dist fs artifacts)
148
+ npm run dev
149
+ # After making changes run the sanity-check task to verify all checks before committing changes
150
+ npm run sanity-check
151
+ ```
152
+
153
+ The dev server will host files on port 8000. Once started, the demo can be found running at http://localhost:8000/demo/.
154
+
155
+ Before submitting a PR, please see our [contribution guidelines](CONTRIBUTING.md).
156
+ Join the discussion on Slack via [video-dev.org](https://video-dev.org) in #hlsjs for updates and questions about development.
157
+
158
+ ### Build tasks
159
+
160
+ Build all flavors (suitable for prod-mode/CI):
161
+
162
+ ```
163
+ npm install ci
164
+ npm run build
165
+ ```
166
+
167
+ Only debug-mode artifacts:
168
+
169
+ ```
170
+ npm run build:debug
171
+ ```
172
+
173
+ Build and watch (customized dev setups where you'll want to host through another server - for example in a sub-module/project)
174
+
175
+ ```
176
+ npm run build:watch
177
+ ```
178
+
179
+ Only specific flavor (known configs are: debug, dist, light, light-dist, demo):
180
+
181
+ ```
182
+ npm run build -- --env dist # replace "dist" by other configuration name, see above ^
183
+ ```
184
+
185
+ Note: The "demo" config is always built.
186
+
187
+ **NOTE:** `hls.light.*.js` dist files do not include alternate-audio, subtitles, CMCD, EME (DRM), or Variable Substitution support. In addition, the following types are not available in the light build:
188
+
189
+ - `AudioStreamController`
190
+ - `AudioTrackController`
191
+ - `CuesInterface`
192
+ - `EMEController`
193
+ - `SubtitleStreamController`
194
+ - `SubtitleTrackController`
195
+ - `TimelineController`
196
+ - `CmcdController`
197
+
198
+ ### Linter (ESlint)
199
+
200
+ Run linter:
201
+
202
+ ```
203
+ npm run lint
204
+ ```
205
+
206
+ Run linter with auto-fix mode:
207
+
208
+ ```
209
+ npm run lint:fix
210
+ ```
211
+
212
+ Run linter with errors only (no warnings)
213
+
214
+ ```
215
+ npm run lint:quiet
216
+ ```
217
+
218
+ ### Formatting Code
219
+
220
+ Run prettier to format code
221
+
222
+ ```
223
+ npm run prettier
224
+ ```
225
+
226
+ ### Type Check
227
+
228
+ Run type-check to verify TypeScript types
229
+
230
+ ```
231
+ npm run type-check
232
+ ```
233
+
234
+ ### Automated tests (Mocha/Karma)
235
+
236
+ Run all tests at once:
237
+
238
+ ```
239
+ npm test
240
+ ```
241
+
242
+ Run unit tests:
243
+
244
+ ```
245
+ npm run test:unit
246
+ ```
247
+
248
+ Run unit tests in watch mode:
249
+
250
+ ```
251
+ npm run test:unit:watch
252
+ ```
253
+
254
+ Run functional (integration) tests:
255
+
256
+ ```
257
+ npm run test:func
258
+ ```
259
+
260
+ ## Design
261
+
262
+ An overview of this project's design, it's modules, events, and error handling can be found [here](/docs/design.md).
263
+
264
+ ## API docs and usage guide
265
+
266
+ - [API and usage docs, with code examples](./docs/API.md)
267
+ - [Auto-Generated API Docs (Latest Release)](https://hlsjs.video-dev.org/api-docs/)
268
+ - [Auto-Generated API Docs (Development Branch)](https://hlsjs-dev.video-dev.org/api-docs/)
269
+
270
+ _Note you can access the docs for a particular version using "[https://github.com/video-dev/hls.js/tree/deployments](https://github.com/video-dev/hls.js/tree/deployments)"_
271
+
272
+ ## Demo
273
+
274
+ ### Latest Release
275
+
276
+ [https://hlsjs.video-dev.org/demo](https://hlsjs.video-dev.org/demo)
277
+
278
+ ### Master
279
+
280
+ [https://hlsjs-dev.video-dev.org/demo](https://hlsjs-dev.video-dev.org/demo)
281
+
282
+ ### Specific Version
283
+
284
+ Find the commit on [https://github.com/video-dev/hls.js/tree/deployments](https://github.com/video-dev/hls.js/tree/deployments).
285
+
286
+ [![](https://opensource.saucelabs.com/images/opensauce/powered-by-saucelabs-badge-gray.png?sanitize=true)](https://saucelabs.com)
287
+
288
+ ## Compatibility
289
+
290
+ HLS.js is only compatible with browsers supporting MediaSource extensions (MSE) API with 'video/MP4' mime-type inputs.
291
+
292
+ HLS.js is supported on:
293
+
294
+ - Chrome 39+ for Android
295
+ - Chrome 39+ for Desktop
296
+ - Firefox 41+ for Android
297
+ - Firefox 42+ for Desktop
298
+ - Edge for Windows 10+
299
+ - Safari 9+ for macOS 10.11+
300
+ - Safari for iPadOS 13+
301
+ - Safari for iOS 17.1+ since HLS version [1.5.0](https://github.com/video-dev/hls.js/releases/tag/v1.5.0) using Managed Media Source (MMS) [WebKit blog](https://webkit.org/blog/14735/webkit-features-in-safari-17-1/)
302
+
303
+ A [Promise polyfill](https://github.com/taylorhakes/promise-polyfill) is required in browsers missing native promise support.
304
+
305
+ **Please note:**
306
+
307
+ Safari browsers (iOS, iPadOS, and macOS) have built-in HLS support through the plain video "tag" source URL. See the example below (Using HLS.js) to run appropriate feature detection and choose between using HLS.js or natively built-in HLS support.
308
+
309
+ When a platform has neither MediaSource nor native HLS support, the browser cannot play HLS.
310
+
311
+ _Keep in mind that if the intention is to support HLS on multiple platforms, beyond those compatible with HLS.js, the HLS streams need to strictly follow the specifications of RFC8216, especially if apps, smart TVs, and set-top boxes are to be supported._
312
+
313
+ Find a support matrix of the MediaSource API here: https://developer.mozilla.org/en-US/docs/Web/API/MediaSource
314
+
315
+ ## Using HLS.js
316
+
317
+ ### Installation
318
+
319
+ Prepackaged builds are included [with each release](https://github.com/video-dev/hls.js/releases). Or install the hls.js as a dependency
320
+ of your project:
321
+
322
+ ```sh
323
+ npm install --save hls.js
324
+ ```
325
+
326
+ A canary channel is also available if you prefer to work off the development branch (master):
327
+
328
+ ```
329
+ npm install hls.js@canary
330
+ ```
331
+
332
+ ### Embedding HLS.js
333
+
334
+ Directly include dist/hls.js or dist/hls.min.js in a script tag on the page. This setup prioritizes HLS.js MSE playback over
335
+ native browser support for HLS playback in HTMLMediaElements:
336
+
337
+ ```html
338
+ <script src="https://cdn.jsdelivr.net/npm/hls.js@1"></script>
339
+ <!-- Or if you want the latest version from the main branch -->
340
+ <!-- <script src="https://cdn.jsdelivr.net/npm/hls.js@canary"></script> -->
341
+ <video id="video"></video>
342
+ <script>
343
+ var video = document.getElementById('video');
344
+ var videoSrc = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
345
+ if (Hls.isSupported()) {
346
+ var hls = new Hls();
347
+ hls.loadSource(videoSrc);
348
+ hls.attachMedia(video);
349
+ }
350
+ // HLS.js is not supported on platforms that do not have Media Source
351
+ // Extensions (MSE) enabled.
352
+ //
353
+ // When the browser has built-in HLS support (check using `canPlayType`),
354
+ // we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video
355
+ // element through the `src` property. This is using the built-in support
356
+ // of the plain video element, without using HLS.js.
357
+ else if (video.canPlayType('application/vnd.apple.mpegurl')) {
358
+ video.src = videoSrc;
359
+ }
360
+ </script>
361
+ ```
362
+
363
+ #### Alternative setup
364
+
365
+ To check for native browser support first and then fallback to HLS.js, swap these conditionals. See [this comment](https://github.com/video-dev/hls.js/pull/2954#issuecomment-670021358) to understand some of the tradeoffs.
366
+
367
+ ```html
368
+ <script src="https://cdn.jsdelivr.net/npm/hls.js@1"></script>
369
+ <!-- Or if you want the latest version from the main branch -->
370
+ <!-- <script src="https://cdn.jsdelivr.net/npm/hls.js@canary"></script> -->
371
+ <video id="video"></video>
372
+ <script>
373
+ var video = document.getElementById('video');
374
+ var videoSrc = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
375
+ //
376
+ // First check for native browser HLS support
377
+ //
378
+ if (video.canPlayType('application/vnd.apple.mpegurl')) {
379
+ video.src = videoSrc;
380
+ //
381
+ // If no native HLS support, check if HLS.js is supported
382
+ //
383
+ } else if (Hls.isSupported()) {
384
+ var hls = new Hls();
385
+ hls.loadSource(videoSrc);
386
+ hls.attachMedia(video);
387
+ }
388
+ </script>
389
+ ```
390
+
391
+ #### Ensure correct time in video
392
+
393
+ HLS transcoding of an original video file often pushes the time of the first frame a bit. If you depend on having an exact match of frame times between original video and HLS stream, you need to account for this:
394
+
395
+ ```javascript
396
+ let tOffset = 0;
397
+ const getAppendedOffset = (eventName, { frag }) => {
398
+ if (frag.type === 'main' && frag.sn !== 'initSegment' && frag.elementaryStreams.video) {
399
+ const { start, startDTS, startPTS, maxStartPTS, elementaryStreams } = frag;
400
+ tOffset = elementaryStreams.video.startPTS - start;
401
+ hls.off(Hls.Events.BUFFER_APPENDED, getAppendedOffset);
402
+ console.log('video timestamp offset:', tOffset, { start, startDTS, startPTS, maxStartPTS, elementaryStreams });
403
+ }
404
+ }
405
+ hls.on(Hls.Events.BUFFER_APPENDED, getAppendedOffset);
406
+ // and account for this offset, for example like this:
407
+ const video = document.querySelector('video');
408
+ video.addEventListener('timeupdate', () => setTime(Math.max(0, video.currentTime - tOffset))
409
+ const seek = (t) => video.currentTime = t + tOffset;
410
+ const getDuration = () => video.duration - tOffset;
411
+ ```
412
+
413
+ For more embed and API examples see [docs/API.md](./docs/API.md).
414
+
415
+ ## CORS
416
+
417
+ All HLS resources must be delivered with [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) permitting `GET` requests.
418
+
419
+ ## Video Control
420
+
421
+ Video is controlled through HTML `<video>` element `HTMLVideoElement` methods, events and optional UI controls (`<video controls>`).
422
+
423
+ ## Build a Custom UI
424
+
425
+ - [Media Chrome](https://github.com/muxinc/media-chrome)
426
+
427
+ ## Player Integration
428
+
429
+ The following players integrate HLS.js for HLS playback:
430
+
431
+ - [JW Player](https://www.jwplayer.com)
432
+ - [Akamai Adaptive Media Player (AMP)](https://www.akamai.com/us/en/solutions/products/media-delivery/adaptive-media-player.jsp)
433
+ - [BridTV Player](https://www.brid.tv)
434
+ - [Clappr](https://github.com/clappr/clappr)
435
+ - [Flowplayer](https://www.flowplayer.org) through [flowplayer-hlsjs](https://github.com/flowplayer/flowplayer-hlsjs)
436
+ - [MediaElement.js](https://www.mediaelementjs.com)
437
+ - [KalturaPlayer](https://developer.kaltura.com) through [kaltura-player-js](https://github.com/kaltura/kaltura-player-js#readme)
438
+ - [Videojs](https://videojs.com) through [Videojs-hlsjs](https://github.com/benjipott/videojs-hlsjs)
439
+ - [Videojs](https://videojs.com) through [videojs-hls.js](https://github.com/streamroot/videojs-hls.js). hls.js is integrated as a SourceHandler -- new feature in Video.js 5.
440
+ - [Videojs](https://videojs.com) through [videojs-contrib-hls.js](https://github.com/Peer5/videojs-contrib-hls.js). Production ready plug-in with full fallback compatibility built-in.
441
+ - [Fluid Player](https://www.fluidplayer.com)
442
+ - [OpenPlayerJS](https://www.openplayerjs.com), as part of the [OpenPlayer project](https://github.com/openplayerjs)
443
+ - [CDNBye](https://github.com/cdnbye/hlsjs-p2p-engine), a p2p engine for hls.js powered by WebRTC Datachannel.
444
+ - [M3U IPTV](http://m3u-ip.tv/browser/)
445
+ - [ArtPlayer](https://artplayer.org/?libs=https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.17/hls.min.js&example=hls)
446
+ - [IPTV Player](https://iptvplayer.stream), A free web-based HLS player that lets you play HLS,DASH and MP4 streams
447
+
448
+ ### They use HLS.js in production!
449
+
450
+ | | | | |
451
+ | :----------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
452
+ | [<img src="https://i.cdn.turner.com/adultswim/big/img/global/adultswim.jpg" width="120">](https://www.adultswim.com/streams) | [<img src="https://avatars3.githubusercontent.com/u/5497190?s=200&v=4" width="120">](https://www.akamai.com) | [<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Canal%2B.svg/2000px-Canal%2B.svg.png" width="120">](https://www.canalplus.fr) | [<img src="https://avatars2.githubusercontent.com/u/115313" width="120">](https://www.dailymotion.com) |
453
+ | [<img src="https://user-images.githubusercontent.com/4006693/44003595-baff193c-9e8f-11e8-9848-7bb91563499f.png" width="120">](https://freshlive.tv) | [<img src="https://user-images.githubusercontent.com/360826/231535440-7cf075f1-bf38-4640-a0a7-d9ff74a1e396.png" width="120">](https://www.mux.com/) | [<img src="https://avatars1.githubusercontent.com/u/12554082?s=240" width="120">](https://www.foxsports.com.au) | [<img src="https://cloud.githubusercontent.com/assets/244265/12556435/dfaceb48-c353-11e5-971b-2c4429725469.png" width="120">](https://www.globo.com) |
454
+ | [<img src="https://images.gunosy.com/logo/gunosy_icon_company_logo.png" width="120">](https://gunosy.com) | [<img src="https://user-images.githubusercontent.com/1480052/35802840-f8e85b8a-0a71-11e8-8eb2-eee323e3f159.png" width="120">](https://www.gl-systemhaus.de/) | [<img src="https://cloud.githubusercontent.com/assets/6525783/20801836/700490de-b7ea-11e6-82bd-e249f91c7bae.jpg" width="120">](https://nettrek.de) | [<img src="https://cloud.githubusercontent.com/assets/244265/12556385/999aa884-c353-11e5-9102-79df54384498.png" width="120">](https://www.nytimes.com/) |
455
+ | [<img src="https://cloud.githubusercontent.com/assets/1798553/20356424/ba158574-ac24-11e6-95e1-1ae591b11a0a.png" width="120">](https://www.peer5.com/) | [<img src="https://cloud.githubusercontent.com/assets/4909096/20925062/e26e6fc8-bbb4-11e6-99a5-d4762274a342.png" width="120">](https://www.qbrick.com) | [<img src="https://www.radiantmediaplayer.com/images/radiantmediaplayer-new-logo-640.jpg" width="120">](https://www.radiantmediaplayer.com/) | [<img src="https://www.rts.ch/hummingbird-static/images/logos/logo_marts.svg" width="120">](https://www.rts.ch) |
456
+ | [<img src="https://cloud.githubusercontent.com/assets/12702747/19316434/0a3601de-9067-11e6-85e2-936b1cb099a0.png" width="120">](https://www.snapstream.com/) | [<img src="https://pamediagroup.com/wp-content/uploads/2019/05/StreamAMG-Logo-RGB.png" width="120">](https://www.streamamg.com/) | [<img src="https://streamsharkio.sa.metacdn.com/wp-content/uploads/2015/10/streamshark-dark.svg" width="120">](https://streamshark.io/) | [<img src="https://camo.githubusercontent.com/9580f10e9bfa8aa7fba52c5cb447bee0757e33da/68747470733a2f2f7777772e7461626c6f74762e636f6d2f7374617469632f696d616765732f7461626c6f5f6c6f676f2e706e67" width="120">](https://my.tablotv.com/) |
457
+ | [<img src="https://user-images.githubusercontent.com/2803310/34083705-349c8fd0-e375-11e7-92a6-5c38509f4936.png" width="120">](https://www.streamroot.io/) | [<img src="https://user-images.githubusercontent.com/360826/231538721-156a865d-a505-45e7-a362-dafbaf2b182f.png" width="120">](https://www.ted.com/) | [<img src="https://www.seeklogo.net/wp-content/uploads/2014/12/twitter-logo-vector-download.jpg" width="120">](https://twitter.com/) | [<img src="https://player.clevercast.com/img/clevercast.png" width="120">](https://www.clevercast.com) |
458
+ | [<img src="https://player.mtvnservices.com/edge/hosted/Viacom_logo.svg" width="120">](https://www.viacom.com/) | [<img src="https://user-images.githubusercontent.com/1181974/29248959-efabc440-802d-11e7-8050-7c1f4ca6c607.png" width="120">](https://vk.com/) | [<img src="https://avatars0.githubusercontent.com/u/5090060?s=200&v=4" width="120">](https://www.jwplayer.com) | [<img src="https://raw.githubusercontent.com/kaltura/kaltura-player-js/master/docs/images/kaltura-logo.svg" width="120">](https://corp.kaltura.com/) |
459
+ | [<img src="https://showmax.akamaized.net/e/logo/showmax_black.png" width="120">](https://tech.showmax.com) | [<img src="https://static3.1tv.ru/assets/web/logo-ac67852f1625b338f9d1fb96be089d03557d50bfc5790d5f48dc56799f59dec6.svg" width="120" height="120">](https://www.1tv.ru/) | [<img src="https://user-images.githubusercontent.com/1480052/40482633-c013ebce-5f55-11e8-96d5-b776415de0ce.png" width="120">](https://www.zdf.de) | [<img src="https://cms-static.brid.tv/img/brid-logo-120x120.jpg" width="120">](https://www.brid.tv/) |
460
+ | [cdn77](https://streaming.cdn77.com/) | [<img src="https://avatars0.githubusercontent.com/u/7442371?s=200&v=4" width="120">](https://r7.com/) | [<img src="https://raw.githubusercontent.com/Novage/p2p-media-loader/gh-pages/images/p2pml-logo.png" width="120">](https://github.com/Novage/p2p-media-loader) | [<img src="https://avatars3.githubusercontent.com/u/45617200?s=400" width="120">](https://kayosports.com.au) |
461
+ | [<img src="https://avatars1.githubusercontent.com/u/5279615?s=400&u=9771a216836c613f1edf4afe71cfc69d4c5657ed&v=4" width="120">](https://flosports.tv) | [<img src="https://www.logolynx.com/images/logolynx/c6/c67a2cb3ad33a82b5518f8ad8f124703.png" width="120">](https://global.axon.com/) | [<img src="https://static.rutube.ru/static/img/svg/logo_rutube_black_color_154x25.svg" width="120">](https://rutube.ru/) | |
462
+
463
+ ## Chrome/Firefox integration
464
+
465
+ made by [gramk](https://github.com/gramk/chrome-hls), plays hls from address bar and m3u8 links
466
+
467
+ - Chrome [native-hls](https://chrome.google.com/webstore/detail/native-hls-playback/emnphkkblegpebimobpbekeedfgemhof)
468
+ - Firefox [native-hls](https://addons.mozilla.org/en-US/firefox/addon/native_hls_playback/)
469
+
470
+ ## License
471
+
472
+ HLS.js is released under [Apache 2.0 License](LICENSE)