Skip to content

Commit

Permalink
修复 fetchError websockeError stremEnd 异常的时候没有结束播放
Browse files Browse the repository at this point in the history
  • Loading branch information
bosscheng committed May 24, 2024
1 parent 6c1e216 commit b95f68e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
3 changes: 3 additions & 0 deletions demo/document.md
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,9 @@ const jessibuca = new JessibucaPro({

3.如果条件允许,把出问题的流,保存个flv文件,发给作者。

#### 日志下载

<img src="/public/img/save-log.png">

### 关于绿屏和花屏

Expand Down
Binary file modified demo/public/dist.zip
Binary file not shown.
Binary file added demo/public/img/save-log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/jessibuca.js

Large diffs are not rendered by default.

40 changes: 35 additions & 5 deletions src/jessibuca.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ class Jessibuca extends Emitter {
}
})
})

//
this.player.once(EVENTS_ERROR.webcodecsH265NotSupport, () => {
this.pause().then(() => {
Expand Down Expand Up @@ -532,20 +531,50 @@ class Jessibuca extends Emitter {
this.play(url, options).then(() => {
// resolve();
this.debug.log('Jessibuca', 'wasm decode error and reset player and play success')
}).catch(() => {
}).catch((e) => {
// reject();
this.debug.warn('Jessibuca', 'wasm decode error and reset player and play error')
});
})
} else {
this.debug.warn('Jessibuca', 'wasm decode error and paused');
this.pause().then(() => {
this.debug.log('Jessibuca', 'wasm decode error and paused');
}).catch((e) => {
this.debug.warn('Jessibuca', 'wasm decode error and paused error', e)
})
}
})
// fetch error
this.player.once(EVENTS_ERROR.fetchError, () => {
this.pause().then(() => {
this.debug.log('Jessibuca', 'fetch error and pause play')
}).catch((e) => {
this.debug.warn('Jessibuca', 'fetch error and pause play error', e)
})
})

//
this.player.once(EVENTS_ERROR.websocketError, () => {
this.pause().then(() => {
this.debug.log('Jessibuca', 'websocket Error and pause play')
}).catch((e) => {
this.debug.warn('Jessibuca', 'websocket Error and pause play error', e)
})
})

//
this.player.once(EVENTS.streamEnd, () => {
this.pause().then(() => {
this.debug.log('Jessibuca', 'stream End and pause play')
}).catch((e) => {
this.debug.warn('Jessibuca', 'stream End and pause play error', e)
})
})

// 监听 delay timeout
this.player.on(EVENTS.delayTimeout, () => {
if (this.player._opt.heartTimeoutReplay && (this._heartTimeoutReplayTimes < this.player._opt.heartTimeoutReplayTimes || this.player._opt.heartTimeoutReplayTimes === -1)) {
if (this.player._opt.heartTimeoutReplay &&
(this._heartTimeoutReplayTimes < this.player._opt.heartTimeoutReplayTimes || this.player._opt.heartTimeoutReplayTimes === -1)) {
this.debug.log('Jessibuca', `delay timeout replay time is ${this._heartTimeoutReplayTimes}`)
this._heartTimeoutReplayTimes += 1;
this.play(url, options).then(() => {
Expand All @@ -559,7 +588,8 @@ class Jessibuca extends Emitter {

// 监听 loading timeout
this.player.on(EVENTS.loadingTimeout, () => {
if (this.player._opt.loadingTimeoutReplay && (this._loadingTimeoutReplayTimes < this.player._opt.loadingTimeoutReplayTimes || this.player._opt.loadingTimeoutReplayTimes === -1)) {
if (this.player._opt.loadingTimeoutReplay &&
(this._loadingTimeoutReplayTimes < this.player._opt.loadingTimeoutReplayTimes || this.player._opt.loadingTimeoutReplayTimes === -1)) {
this.debug.log('Jessibuca', `loading timeout replay time is ${this._loadingTimeoutReplayTimes}`)
this._loadingTimeoutReplayTimes += 1;
this.play(url, options).then(() => {
Expand Down
11 changes: 7 additions & 4 deletions src/player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,20 @@ export default class Player extends Emitter {
this.checkLoadingTimeout();
// fetch error
this.stream.once(EVENTS_ERROR.fetchError, (error) => {
reject(error)
// reject(error)
this.emitError(EVENTS_ERROR.fetchError, error);
})

// ws
this.stream.once(EVENTS_ERROR.websocketError, (error) => {
reject(error)
// reject(error)
this.emitError(EVENTS_ERROR.websocketError, error);
})

// stream end
this.stream.once(EVENTS.streamEnd, () => {
reject();
this.stream.once(EVENTS.streamEnd, (msg) => {
// reject();
this.emitError(EVENTS.streamEnd, msg);
})

// success
Expand Down

0 comments on commit b95f68e

Please sign in to comment.