UNPKG

2.05 kBMarkdownView Raw
1# Playlist Loader
2
3## Purpose
4
5The [PlaylistLoader][pl] (PL) is responsible for requesting m3u8s, parsing them and keeping track of the media "playlists" associated with the manifest. The [PL] is used with a [SegmentLoader] to load ts or fmp4 fragments from an HLS source.
6
7## Basic Responsibilities
8
91. To request an m3u8.
102. To parse a m3u8 into a format [videojs-http-streaming][vhs] can understand.
113. To allow selection of a specific media stream.
124. To refresh a live master m3u8 for changes.
13
14## Design
15
16### States
17
18![PlaylistLoader States](images/playlist-loader-states.nomnoml.svg)
19
20- `HAVE_NOTHING` the state before the m3u8 is received and parsed.
21- `HAVE_MASTER` the state before a media manifest is parsed and setup but after the master manifest has been parsed and setup.
22- `HAVE_METADATA` the state after a media stream is setup.
23- `SWITCHING_MEDIA` the intermediary state we go though while changing to a newly selected media playlist
24- `HAVE_CURRENT_METADATA` a temporary state after requesting a refresh of the live manifest and before receiving the update
25
26### API
27
28- `load()` this will either start or kick the loader during playback.
29- `start()` this will start the [PL] and request the m3u8.
30- `media()` this will return the currently active media stream or set a new active media stream.
31
32### Events
33
34- `loadedplaylist` signals the setup of a master playlist, representing the HLS source as a whole, from the m3u8; or a media playlist, representing a media stream.
35- `loadedmetadata` signals initial setup of a media stream.
36- `playlistunchanged` signals that no changes have been made to a m3u8.
37- `mediaupdatetimeout` signals that a live m3u8 and media stream must be refreshed.
38- `mediachanging` signals that the currently active media stream is going to be changed.
39- `mediachange` signals that the new media stream has been updated.
40
41### Interaction with Other Modules
42
43![PL with MPC and MG](images/playlist-loader-mpc-mg-sequence.plantuml.png)
44
45[pl]: ../src/playlist-loader.js
46[sl]: ../src/segment-loader.js
47[vhs]: intro.md