Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard coded segmentMimiTypes, why? #8

Open
sberryman opened this issue May 23, 2019 · 3 comments
Open

Hard coded segmentMimiTypes, why? #8

sberryman opened this issue May 23, 2019 · 3 comments

Comments

@sberryman
Copy link

https://github.com/kanongil/node-hls-segment-reader/blob/86499532f115a17b6ba98bd6209a1cd1c45ae090/lib/segment-reader.js#L32-L47

You have hard coded that array and I've run into a case where I have a MIME type of application/octet-stream. I've also come across MIME type of application/binary

Thoughts on allowing a user to override or push values into the set?

@kanongil
Copy link
Owner

Yes. Currently, it can be "hacked" by subclassing the reader, and providing your own segmentMimeTypes() getter.

I'm open to adding an actual option (probably as a function that is called to verify the mime type).

@sberryman
Copy link
Author

I'm open for a function to verify the type. Thanks for the great code though, it is the perfect way for me to dump HLS streams to disk. So glad you posted the decrypt code https://github.com/kanongil/node-hls-tools/blob/master/lib/segment-decrypt.js in that project as well.

@ox-michaelradionov
Copy link

ox-michaelradionov commented Oct 24, 2019

For anyone interested in adding an extra mime type using a "hack" provided by @kanongil above, here is an implementation

const HLSSegmentReader = require('hls-segment-reader');

class ExtendedHLSSegmentReader extends HLSSegmentReader {

  get segmentMimeTypes() {
    const extendedMimeTypes = new Set(super.segmentMimeTypes);
    extendedMimeTypes.add('application/octet-stream');
    return extendedMimeTypes;
  }

}

const reader = new ExtendedHLSSegmentReader('foo.m3u8');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants