Skip to content

Commit

Permalink
feat: expose m3u8-parser logging in debug log (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Jan 21, 2021
1 parent caa8ff2 commit 0e8bd4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ export const createPlaylistID = (index, uri) => {
* The manifest object
*/
export const parseManifest = ({
onwarn,
oninfo,
manifestString,
customTagParsers = [],
customTagMappers = []
}) => {
const parser = new M3u8Parser();

if (onwarn) {
parser.on('warn', onwarn);
}
if (oninfo) {
parser.on('info', oninfo);
}

customTagParsers.forEach(customParser => parser.addParser(customParser));
customTagMappers.forEach(mapper => parser.addTagMapper(mapper));

Expand Down
4 changes: 4 additions & 0 deletions src/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { resolveUrl, resolveManifestRedirect } from './resolve-url';
import videojs from 'video.js';
import window from 'global/window';
import logger from './util/logger';
import {
parseManifest,
addPropertiesToMaster,
Expand Down Expand Up @@ -157,6 +158,7 @@ export default class PlaylistLoader extends EventTarget {
if (!src) {
throw new Error('A non-empty playlist URL or object is required');
}
this.logger_ = logger('PlaylistLoader');

const { withCredentials = false, handleManifestRedirects = false } = options;

Expand Down Expand Up @@ -246,6 +248,8 @@ export default class PlaylistLoader extends EventTarget {
this.state = 'HAVE_METADATA';

const playlist = playlistObject || parseManifest({
onwarn: ({message}) => this.logger_(`m3u8-parser warn for ${id}: ${message}`),
oninfo: ({message}) => this.logger_(`m3u8-parser info for ${id}: ${message}`),
manifestString: playlistString,
customTagParsers: this.customTagParsers,
customTagMappers: this.customTagMappers
Expand Down

0 comments on commit 0e8bd4b

Please sign in to comment.