Skip to content

Commit

Permalink
Merge pull request video-dev#1734 from oldmtn/master
Browse files Browse the repository at this point in the history
Add a regex to check different mp4 suffix.
  • Loading branch information
tjenkinson authored Jun 1, 2018
2 parents 93b5348 + ae297c2 commit a7e49cb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/loader/m3u8-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const LEVEL_PLAYLIST_REGEX_FAST = new RegExp([

const LEVEL_PLAYLIST_REGEX_SLOW = /(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)(.*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/;

const MP4_REGEX_SUFFIX = /\.(mp4|m4s|m4v|m4a)$/i;

export default class M3U8Parser {
static findGroup (groups, mediaGroupId) {
if (!groups) {
Expand Down Expand Up @@ -314,9 +316,7 @@ export default class M3U8Parser {
// this is a bit lurky but HLS really has no other way to tell us
// if the fragments are TS or MP4, except if we download them :/
// but this is to be able to handle SIDX.
// FIXME: replace string test by a regex that matches
// also `m4s` `m4a` `m4v` and other popular extensions
if (level.fragments.every((frag) => frag.relurl.endsWith('.mp4'))) {
if (level.fragments.every((frag) => MP4_REGEX_SUFFIX.test(frag.relurl))) {
logger.warn('MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX');

frag = new Fragment();
Expand Down

0 comments on commit a7e49cb

Please sign in to comment.