Skip to content

Commit 50ffb36

Browse files
committed
fix: flv error controll
1 parent 4b474ed commit 50ffb36

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

packages/mpegts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@oplayer/mpegts",
3-
"version": "1.2.25",
3+
"version": "1.2.26-beta.0",
44
"description": "mpegts.js plugin for oplayer",
55
"type": "module",
66
"main": "./dist/index.es.js",

packages/mpegts/src/index.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)