Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tedconf/node-m3u8
Streaming parser for m3u8 files in node
https://github.com/tedconf/node-m3u8
Last synced: 3 months ago
JSON representation
Streaming parser for m3u8 files in node
- Host: GitHub
- URL: https://github.com/tedconf/node-m3u8
- Owner: tedconf
- License: mit
- Created: 2012-10-30T16:24:02.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2021-11-22T16:14:40.000Z (almost 3 years ago)
- Last Synced: 2024-07-26T23:51:34.702Z (3 months ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 189
- Watchers: 33
- Forks: 77
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
m3u8
====node-m3u8 is a streaming m3u8 parser tailored for dealing with [Apple's HTTP
Live Streaming protocol](http://tools.ietf.org/html/draft-pantos-http-live-streaming).
It may work for other m3u files, but I have not tested it for those uses.example
-------``` js
var m3u8 = require('m3u8');
var fs = require('fs');var parser = m3u8.createStream();
var file = fs.createReadStream('/path/to/file.m3u8');
file.pipe(parser);parser.on('item', function(item) {
// emits PlaylistItem, MediaItem, StreamItem, and IframeStreamItem
});
parser.on('m3u', function(m3u) {
// fully parsed m3u file
});
```All items and the m3u object have `toString()` methods for conversion to m3u8.
Attributes and properties have getter/setters on m3u and item objects:```
parser.on('item', function(item) {
var duration = item.get('bandwidth');
item.set('uri', 'http://example.com/' + item.get('uri'));
});
```The M3U and Item objects are available on m3u8:
```
var m3u8 = require('m3u8');var m3u = m3u8.M3U.create();
m3u.addPlaylistItem({
duration : 10,
uri : 'file'
});
```See tests for more usage patterns.