Skip to content
This repository was archived by the owner on May 22, 2019. It is now read-only.

codl/hls-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hls.js

Build Status

hls.js is a library for parsing the contents of a M3U playlist according to the HLS specification.

Usage

var contents = `#EXTM3U
#EXT-X-TARGETDURATION:60
#EXT-X-ALLOW-CACHE:NO

#EXT-X-PROGRAM-DATE-TIME:2015-07-13T21:27:10+0200
#EXTINF:60,
http://example.com/0.ts
#EXT-X-DISCONTINUITY
#EXT-X-PROGRAM-DATE-TIME:2015-07-13T21:34:09+0200
#EXTINF:60,
http://example.com/1.ts
#EXT-X-PROGRAM-DATE-TIME:2015-07-13T21:35:09+0200
#EXTINF:46,
http://example.com/2.ts
`

var playlist = hls(contents);
console.dir(playlist);
/*
    {
        "type": "media",
        "target_duration": 60,
        "cacheable": false,
        "segments": [
            {
                "time": new Date("2015-07-13T21:27:10+0200"),
                "duration": 60,
                "url": "http://example.com/0.ts",
                "encrypted": false,
                "encryption_method": "NONE"
            },
            {
                "discontinuous": true,
                "time": new Date("2015-07-13T21:34:09+0200"),
                "duration": 60,
                "url": "http://example.com/1.ts",
                "encrypted": false,
                "encryption_method": "NONE"
            },
            {
                "time": new Date("2015-07-13T21:35:09+0200"),
                "duration": 46,
                "url": "http://example.com/1.ts",
                "encrypted": false,
                "encryption_method": "NONE"
            },
            "low": 0,
            "high": 2 ]
    }
*/

refer to tests.js for something approaching a reference because i'm too lazy to make one

About

a parser for HLS M3U playlists

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors