|
|
@@ -155,30 +155,29 @@ function HlsStreamReader(src, options) {
|
|
|
var stream = uristream(url.format(self.url), { timeout:30*1000 });
|
|
|
stream.on('meta', function(meta) {
|
|
|
if (meta.mime !== 'application/vnd.apple.mpegurl' &&
|
|
|
- meta.mime !== 'application/x-mpegurl' && meta.mime !== 'audio/mpegurl')
|
|
|
+ meta.mime !== 'application/x-mpegurl' && meta.mime !== 'audio/mpegurl') {
|
|
|
+ // FIXME: correctly handle .m3u us-ascii encoding
|
|
|
+ if (stream.abort) stream.abort();
|
|
|
return stream.emit('error', new Error('Invalid MIME type: '+meta.mime));
|
|
|
- // FIXME: correctly handle .m3u us-ascii encoding
|
|
|
+ }
|
|
|
|
|
|
self.baseUrl = meta.url;
|
|
|
});
|
|
|
|
|
|
m3u8.parse(stream, function(err, index) {
|
|
|
if (err) {
|
|
|
- if (self.index && self.keepConnection) {
|
|
|
- console.error('Failed to parse index at '+url.format(self.url)+':', err.stack || err);
|
|
|
- return updatecheck(false);
|
|
|
+ self.emit('error', err);
|
|
|
+ updatecheck(false);
|
|
|
+ } else {
|
|
|
+ var updated = true;
|
|
|
+ if (self.index && self.index.lastSeqNo() === index.lastSeqNo()) {
|
|
|
+ debug('index was not updated');
|
|
|
+ updated = false;
|
|
|
}
|
|
|
- return self.emit('error', err);
|
|
|
- }
|
|
|
|
|
|
- var updated = true;
|
|
|
- if (self.index && self.index.lastSeqNo() === index.lastSeqNo()) {
|
|
|
- debug('index was not updated');
|
|
|
- updated = false;
|
|
|
+ self.index = index;
|
|
|
+ updatecheck(updated);
|
|
|
}
|
|
|
-
|
|
|
- self.index = index;
|
|
|
- updatecheck(updated);
|
|
|
});
|
|
|
}
|
|
|
updateindex();
|