Skip to content

Commit

Permalink
Update usage example (kuu#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
kot-lex authored Apr 5, 2024
1 parent e3b433d commit 93002be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ Provides synchronous functions to read/write HLS playlists (conforms to [the HLS

## Usage
```js
import HLS from 'hls-parser';
import { parse, types, stringify } from 'hls-parser';

// Parse the playlist
const playlist = HLS.parse(textData);
const playlist = parse(textData);
// You can access the playlist as a JS object
if (playlist.isMasterPlaylist) {
// Master playlist
} else {
// Media playlist
}
// Create a new playlist
const {MediaPlaylist, Segment} = HLS.types;
const {MediaPlaylist, Segment} = types;
const obj = new MediaPlaylist({
targetDuration: 9,
playlistType: 'VOD',
Expand All @@ -38,7 +38,7 @@ const obj = new MediaPlaylist({
]
});
// Convert the object into a text
HLS.stringify(obj);
stringify(obj);
/*
#EXTM3U
#EXT-X-TARGETDURATION:9
Expand Down

0 comments on commit 93002be

Please sign in to comment.