View Source ExM3U8 (ExM3U8 v0.10.0)
ExM3u8
A library for deserializing and serializing M3U8 format (known from HLS).
functionality
Functionality
The whole package operates on 2 types of playlists mentioned in HLS specification.
- Multivariant playlist
- Media playlist
Multivariant playlist is responsible for listing available renditions (video, audio and subtitle tracks).
Each variant is represented by its own media playlist which lists media segments that are necessary to start a proper playback.
Note
Due to the large number of tags in the HLS spec, the library for now only supports the essential ones. If a tag is missing a user may want to implement a custom tag parser or create a PR with a support for the new tag.
Link to this section Summary
Types
Signature of a custom tag parser function.
Functions
Deserializes given playlist string into a media playlist structure.
Sames as deserialize_media_playlist/2
but raises on error.
Deserialies given playlist string into a multivariant playlist structure.
Tries to deserialize playlist string into either a multivariant playlist or a media playlist.
Same as deserialize_playlist/2
but raises on error.
Serializes given playlist into a string.
Link to this section Types
@type custom_tag_parser_t() :: (line :: String.t(), lines :: [String.t()] -> custom_tag_parser_reusult_t())
Signature of a custom tag parser function.
A custom parser is called on each line that a built-in parser couldn't handle. As an input it receives the current line and the remaining lines of the original string. As a result it should either skip the current lilne, return a tag and new list of remaining lines (handling a targ could take several lines) or return an error.
Note that the custom parser will be only used for tags/lines that haven't been handled by the built-in parser so it can't override the default handling of supported tags.
@type deserialize_opt_t() :: {:custom_tag_parser, custom_tag_parser_t()}
Link to this section Functions
@spec deserialize_media_playlist(String.t(), [deserialize_opt_t()]) :: {:ok, ExM3U8.MediaPlaylist.t()} | {:error, term()}
Deserializes given playlist string into a media playlist structure.
@spec deserialize_media_playlist!(String.t(), [deserialize_opt_t()]) :: ExM3U8.MediaPlaylist.t()
Sames as deserialize_media_playlist/2
but raises on error.
@spec deserialize_multivariant_playlist(String.t(), [deserialize_opt_t()]) :: {:ok, ExM3U8.MultivariantPlaylist.t()} | {:error, term()}
Deserialies given playlist string into a multivariant playlist structure.
@spec deserialize_multivariant_playlist!(String.t(), [deserialize_opt_t()]) :: ExM3U8.MultivariantPlaylist.t()
@spec deserialize_playlist(String.t(), [deserialize_opt_t()]) :: {:ok, ExM3U8.MultivariantPlaylist.t() | ExM3U8.MediaPlaylist.t()} | {:error, term()}
Tries to deserialize playlist string into either a multivariant playlist or a media playlist.
Note that this function first tries to deserialize a multivariant playlist and if it failes it tries to deserialize a media playlist so any errors from multivariant playlist parsing will be ignored and the eventual error will come from media playlist parsing.
@spec deserialize_playlist!(String.t(), [deserialize_opt_t()]) :: ExM3U8.MultivariantPlaylist.t() | ExM3U8.MediaPlaylist.t()
Same as deserialize_playlist/2
but raises on error.
@spec serialize(ExM3U8.MediaPlaylist.t() | ExM3U8.MultivariantPlaylist.t()) :: String.t()
Serializes given playlist into a string.