@@ -62,10 +62,16 @@ class MpegtsPlugin implements PlayerPlugin {
6262 ( globalThis as any ) . mpegts ||
6363 //@ts -expect-error
6464 ( library ? await loadSDK ( library , 'mpegts' ) : ( await import ( 'mpegts.js/dist/mpegts.js' ) ) . default )
65+
66+ MpegtsPlugin . library . LoggingControl . applyConfig ( {
67+ enableAll : false
68+ } )
6569 }
6670
6771 if ( ! MpegtsPlugin . library . isSupported ( ) ) return false
6872
73+ MpegtsPlugin . library . LoggingControl . addLogListener ( this . logListener . bind ( this ) )
74+
6975 this . instance = MpegtsPlugin . library . createPlayer (
7076 {
7177 url : source . src ,
@@ -75,25 +81,21 @@ class MpegtsPlugin implements PlayerPlugin {
7581 this . options . config
7682 )
7783
78- const { player, instance } = this
79-
80- instance . on ( MpegtsPlugin . library . Events . ERROR , function ( _ , data ) {
81- const { type, details, fatal } = data
82-
83- if ( fatal ) {
84- player . hasError = true
85- player . emit ( 'error' , { ...data , pluginName : PLUGIN_NAME , message : type + ': ' + details } )
86- }
87- } )
88-
89- instance . attachMediaElement ( $video )
90- instance . load ( )
84+ this . instance . attachMediaElement ( $video )
85+ this . instance . load ( )
9186
9287 return this
9388 }
9489
9590 destroy ( ) {
9691 this . instance ?. destroy ( )
92+ MpegtsPlugin . library . LoggingControl . removeLogListener ( this . logListener . bind ( this ) )
93+ }
94+
95+ logListener ( level : string , msg : string ) {
96+ if ( level === 'error' ) {
97+ this . player . emit ( 'error' , { level, msg, pluginName : PLUGIN_NAME , message : msg } )
98+ }
9799 }
98100}
99101
0 commit comments