HLS.js: Add support for custom logger object in debug option

This commit is contained in:
Johan Brook
2019-01-07 10:41:24 +01:00
parent 3ad75fac4d
commit f968fb1e6c
2 changed files with 21 additions and 3 deletions
+8 -1
View File
@@ -23,7 +23,14 @@ class pLoader extends Hls.DefaultConfig.loader {
if (Hls.isSupported()) {
const video = <HTMLVideoElement> document.getElementById('video');
const hls = new Hls({ pLoader, startFragPrefetch: true });
const hls = new Hls({
pLoader,
startFragPrefetch: true,
debug: {
log: (...args: any[]) => console.log(...args)
}
});
const version: string = Hls.version;
hls.loadSource('http://www.streambox.fr/playlists/test_001/stream.m3u8');
hls.attachMedia(video);
+13 -2
View File
@@ -1,8 +1,9 @@
// Type definitions for hls.js 0.10
// Project: https://github.com/video-dev/hls.js
// Definitions by: John G. Gainfort, Jr. <https://github.com/jgainfort>
// Johan Brook <https://github.com/brookback>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.4
// Event Keys
type K_MEDIA_ATTACHING = "hlsMediaAttaching";
@@ -307,6 +308,16 @@ declare namespace Hls {
// interface SubtitleTracks {}
type CustomLogger = (...args: any[]) => void;
interface CustomLoggerObject {
warn?: CustomLogger;
info?: CustomLogger;
log?: CustomLogger;
debug?: CustomLogger;
error?: CustomLogger;
}
interface Config {
/**
* (default: false)
@@ -319,7 +330,7 @@ declare namespace Hls {
* setting config.debug = true; will turn on debug logs on JS console.
* a logger object could also be provided for custom logging: config.debug = customLogger;
*/
debug: boolean;
debug: boolean | CustomLoggerObject;
/**
* (default: true)
* if set to true, start level playlist and first fragments will be loaded automatically, after triggering of Hls.Events.MANIFEST_PARSED event