@besovideo/webrtc-player 0.8.99 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -117,7 +117,7 @@ var bvPlayerCore = (() => {
117
117
  var define_processenv_default;
118
118
  var init_define_processenv = __esm({
119
119
  "<define:processenv>"() {
120
- define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.8.99", PROJECT_NAMESPACE: "bvplayer" };
120
+ define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.9.1", PROJECT_NAMESPACE: "bvplayer" };
121
121
  }
122
122
  });
123
123
 
@@ -5104,8 +5104,16 @@ padding: 2px 5px;
5104
5104
  signal
5105
5105
  );
5106
5106
  logger_default.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 bvrtc\u65B9\u5F0F\u6253\u5F00dialog: ", { params, resData });
5107
- if (!resData || resData.code !== 0 || !((_a = resData.data) == null ? void 0 : _a.dialogid))
5108
- throw new OpenDialogError(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25: ${resData.msg}`);
5107
+ if (!resData || resData.code !== 0 || !((_a = resData.data) == null ? void 0 : _a.dialogid)) {
5108
+ if (resData.code == 7) {
5109
+ throw new OpenDialogError(
5110
+ `${t("hui-fang-wen-jian-bu-cun-zai")}`
5111
+ );
5112
+ }
5113
+ throw new OpenDialogError(
5114
+ `${t("da-kai-chuan-shu-tong-dao-shi-bai")}: ${resData.msg}`
5115
+ );
5116
+ }
5109
5117
  const { data: dialog } = resData;
5110
5118
  if (dialog.dialogid) {
5111
5119
  const ids = storage_default.get(DialogIdsKey) || [];
@@ -15098,7 +15106,10 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
15098
15106
  "yi-dong-su-du": "Speed",
15099
15107
  "she-bei-bu-zhi-chi": "Not support",
15100
15108
  "mei-you-yun-tai-quan-xian": "No PTZ Permission",
15101
- "wei-zhi-cuo-wu": "Unknown Error"
15109
+ "wei-zhi-cuo-wu": "Unknown Error",
15110
+ "lian-jie-yi-wai-guan-bi": "Unexpected closure",
15111
+ "da-kai-chuan-shu-tong-dao-shi-bai": "Failed to open transmission channel",
15112
+ "hui-fang-wen-jian-bu-cun-zai": "File Not Found"
15102
15113
  };
15103
15114
 
15104
15115
  // src/locales/zh.json
@@ -15154,7 +15165,10 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
15154
15165
  "yi-dong-su-du": "\u79FB\u52A8\u901F\u5EA6",
15155
15166
  "she-bei-bu-zhi-chi": "\u8BBE\u5907\u4E0D\u652F\u6301",
15156
15167
  "mei-you-yun-tai-quan-xian": "\u6CA1\u6709\u4E91\u53F0\u6743\u9650",
15157
- "wei-zhi-cuo-wu": "\u672A\u77E5\u9519\u8BEF"
15168
+ "wei-zhi-cuo-wu": "\u672A\u77E5\u9519\u8BEF",
15169
+ "lian-jie-yi-wai-guan-bi": "\u8FDE\u63A5\u610F\u5916\u5173\u95ED",
15170
+ "da-kai-chuan-shu-tong-dao-shi-bai": "\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25",
15171
+ "hui-fang-wen-jian-bu-cun-zai": "\u56DE\u653E\u6587\u4EF6\u4E0D\u5B58\u5728"
15158
15172
  };
15159
15173
 
15160
15174
  // src/locales/i18n.ts
@@ -18000,14 +18014,15 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
18000
18014
  fileName,
18001
18015
  token,
18002
18016
  locale = "zh",
18003
- type: type1 = "web",
18017
+ type: type1 = "auto",
18004
18018
  zIndexMenu,
18005
18019
  displayMode
18006
18020
  } = __spreadValues(__spreadValues({}, defaultProps3), props);
18007
18021
  i18n_default(locale);
18008
18022
  let hplayer = void 0;
18009
18023
  const handle2 = {};
18010
- let type = (puOption == null ? void 0 : puOption.puId) && type1 == "ws-bvrtc" ? type1 : type1;
18024
+ const isWebErrorAutoToWsBvrtc = type1 == "auto";
18025
+ let type = type1 == "ws-bvrtc" ? type1 : "web";
18011
18026
  const instance2 = {
18012
18027
  videoFit: "contain",
18013
18028
  open() {
@@ -18081,6 +18096,23 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
18081
18096
  });
18082
18097
  if (this.protocol == "web") {
18083
18098
  const videoEle = player.video.getVideoEl();
18099
+ videoEle.onerror = () => {
18100
+ var _a3;
18101
+ if (videoEle.src != "") {
18102
+ if (videoEle.error && videoEle.error.code == MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) {
18103
+ player.mask.text = t("hui-fang-wen-jian-bu-cun-zai");
18104
+ player.mask.visible = true;
18105
+ } else if (videoEle.error && videoEle.error.code == MediaError.MEDIA_ERR_DECODE) {
18106
+ player.mask.text = "\u89E3\u7801\u5931\u8D25";
18107
+ player.mask.visible = true;
18108
+ }
18109
+ if (isWebErrorAutoToWsBvrtc) {
18110
+ (_a3 = handle2.close) == null ? void 0 : _a3.call(handle2);
18111
+ instance2.setProtocol("ws-bvrtc");
18112
+ instance2.open();
18113
+ }
18114
+ }
18115
+ };
18084
18116
  videoEle.src = dialog_default.getPlaybackFilePath({ fileId: fileID, puid: puOption == null ? void 0 : puOption.puId }, token);
18085
18117
  videoEle.controls = false;
18086
18118
  barHandle.addEventListener("changeVolume", (data) => {
@@ -18125,6 +18157,8 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
18125
18157
  }
18126
18158
  });
18127
18159
  handle2.close = () => {
18160
+ videoEle.onerror = () => {
18161
+ };
18128
18162
  videoEle.src = "";
18129
18163
  markerHandle.destroy();
18130
18164
  player.close();
@@ -18168,19 +18202,47 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
18168
18202
  throw new Error("ws-bvrtc create offer failed.");
18169
18203
  }
18170
18204
  logger_default.info("ws-bvrtc localSDP: ", (_c = res == null ? void 0 : res.data) == null ? void 0 : _c.sdp);
18171
- const [dialog, playbackController] = yield dialog_default.getPlaybackBvrtc({
18172
- sdp: (_d = res == null ? void 0 : res.data) == null ? void 0 : _d.sdp,
18173
- id: (puOption == null ? void 0 : puOption.puId) || (puOption == null ? void 0 : puOption.nruId)
18174
- }, token);
18205
+ let dialogId = "";
18206
+ let sdp = "";
18207
+ let playbackController = {};
18208
+ try {
18209
+ const [dialog, playbackControllerTemp] = yield dialog_default.getPlaybackBvrtc({
18210
+ sdp: (_d = res == null ? void 0 : res.data) == null ? void 0 : _d.sdp,
18211
+ id: (puOption == null ? void 0 : puOption.puId) || (puOption == null ? void 0 : puOption.nruId)
18212
+ }, token);
18213
+ playbackController = playbackControllerTemp;
18214
+ dialogId = dialog.dialogId;
18215
+ sdp = dialog.sdp;
18216
+ } catch (e) {
18217
+ const openError = e;
18218
+ player.mask.text = openError.message;
18219
+ player.mask.visible = true;
18220
+ handle2.close = () => {
18221
+ var _a3;
18222
+ markerHandle.destroy();
18223
+ player.close();
18224
+ (_a3 = playbackController.close) == null ? void 0 : _a3.call(playbackController);
18225
+ hplayer == null ? void 0 : hplayer.playbackStop();
18226
+ hplayer.close();
18227
+ barHandle.destroy();
18228
+ contextIns == null ? void 0 : contextIns();
18229
+ jumpEventHandler.destory();
18230
+ handle2.close = void 0;
18231
+ handle2.pause = void 0;
18232
+ handle2.resume = void 0;
18233
+ hplayer = void 0;
18234
+ };
18235
+ return;
18236
+ }
18175
18237
  hplayer.onevent = (bCloseEvent, iResult) => {
18176
18238
  if (bCloseEvent && handle2.close) {
18177
- player.mask.text = "\u8FDE\u63A5\u610F\u5916\u5173\u95ED" + iResult;
18239
+ player.mask.text = t("lian-jie-yi-wai-guan-bi") + iResult;
18178
18240
  player.mask.visible = true;
18179
18241
  barHandle.disable();
18180
18242
  stopInterval();
18181
18243
  }
18182
18244
  };
18183
- hplayer.setRemoteSDP(dialog.dialogId, dialog.sdp);
18245
+ hplayer.setRemoteSDP(dialogId, sdp);
18184
18246
  const playbackInfo = yield playbackController.play();
18185
18247
  hplayer == null ? void 0 : hplayer.playbackStart(1);
18186
18248
  player.addEventListener("refreshInfoModal", (e) => __async(this, null, function* () {
@@ -18231,6 +18293,7 @@ registerProcessor('bv-audio-processor', BVAudioProcessor);
18231
18293
  (_b2 = handle2.resume) == null ? void 0 : _b2.call(handle2);
18232
18294
  }
18233
18295
  });
18296
+ barHandle.pausePlayStateChange("pause");
18234
18297
  const stopInterval = () => {
18235
18298
  if (intervalToken) {
18236
18299
  clearInterval(intervalToken);
package/dist/main.es.js CHANGED
@@ -111,7 +111,7 @@ var __async = (__this, __arguments, generator) => {
111
111
  var define_processenv_default;
112
112
  var init_define_processenv = __esm({
113
113
  "<define:processenv>"() {
114
- define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.8.99", PROJECT_NAMESPACE: "bvplayer" };
114
+ define_processenv_default = { NODE_ENV: "production", SH_LIB_NAME: "@besovideo/webrtc-player", SH_LIB_VERSION: "0.9.1", PROJECT_NAMESPACE: "bvplayer" };
115
115
  }
116
116
  });
117
117
 
@@ -5088,8 +5088,16 @@ var getPlaybackBvrtc = (param, token, signal) => __async(void 0, null, function*
5088
5088
  signal
5089
5089
  );
5090
5090
  logger_default.api("\u8BBE\u5907\u97F3\u89C6\u9891\u6D41 bvrtc\u65B9\u5F0F\u6253\u5F00dialog: ", { params, resData });
5091
- if (!resData || resData.code !== 0 || !((_a = resData.data) == null ? void 0 : _a.dialogid))
5092
- throw new OpenDialogError(`\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25: ${resData.msg}`);
5091
+ if (!resData || resData.code !== 0 || !((_a = resData.data) == null ? void 0 : _a.dialogid)) {
5092
+ if (resData.code == 7) {
5093
+ throw new OpenDialogError(
5094
+ `${t("hui-fang-wen-jian-bu-cun-zai")}`
5095
+ );
5096
+ }
5097
+ throw new OpenDialogError(
5098
+ `${t("da-kai-chuan-shu-tong-dao-shi-bai")}: ${resData.msg}`
5099
+ );
5100
+ }
5093
5101
  const { data: dialog } = resData;
5094
5102
  if (dialog.dialogid) {
5095
5103
  const ids = storage_default.get(DialogIdsKey) || [];
@@ -15082,7 +15090,10 @@ var en_default = {
15082
15090
  "yi-dong-su-du": "Speed",
15083
15091
  "she-bei-bu-zhi-chi": "Not support",
15084
15092
  "mei-you-yun-tai-quan-xian": "No PTZ Permission",
15085
- "wei-zhi-cuo-wu": "Unknown Error"
15093
+ "wei-zhi-cuo-wu": "Unknown Error",
15094
+ "lian-jie-yi-wai-guan-bi": "Unexpected closure",
15095
+ "da-kai-chuan-shu-tong-dao-shi-bai": "Failed to open transmission channel",
15096
+ "hui-fang-wen-jian-bu-cun-zai": "File Not Found"
15086
15097
  };
15087
15098
 
15088
15099
  // src/locales/zh.json
@@ -15138,7 +15149,10 @@ var zh_default = {
15138
15149
  "yi-dong-su-du": "\u79FB\u52A8\u901F\u5EA6",
15139
15150
  "she-bei-bu-zhi-chi": "\u8BBE\u5907\u4E0D\u652F\u6301",
15140
15151
  "mei-you-yun-tai-quan-xian": "\u6CA1\u6709\u4E91\u53F0\u6743\u9650",
15141
- "wei-zhi-cuo-wu": "\u672A\u77E5\u9519\u8BEF"
15152
+ "wei-zhi-cuo-wu": "\u672A\u77E5\u9519\u8BEF",
15153
+ "lian-jie-yi-wai-guan-bi": "\u8FDE\u63A5\u610F\u5916\u5173\u95ED",
15154
+ "da-kai-chuan-shu-tong-dao-shi-bai": "\u6253\u5F00\u4F20\u8F93\u901A\u9053\u5931\u8D25",
15155
+ "hui-fang-wen-jian-bu-cun-zai": "\u56DE\u653E\u6587\u4EF6\u4E0D\u5B58\u5728"
15142
15156
  };
15143
15157
 
15144
15158
  // src/locales/i18n.ts
@@ -17984,14 +17998,15 @@ var PlayBack = (props) => {
17984
17998
  fileName,
17985
17999
  token,
17986
18000
  locale = "zh",
17987
- type: type1 = "web",
18001
+ type: type1 = "auto",
17988
18002
  zIndexMenu,
17989
18003
  displayMode
17990
18004
  } = __spreadValues(__spreadValues({}, defaultProps3), props);
17991
18005
  i18n_default(locale);
17992
18006
  let hplayer = void 0;
17993
18007
  const handle2 = {};
17994
- let type = (puOption == null ? void 0 : puOption.puId) && type1 == "ws-bvrtc" ? type1 : type1;
18008
+ const isWebErrorAutoToWsBvrtc = type1 == "auto";
18009
+ let type = type1 == "ws-bvrtc" ? type1 : "web";
17995
18010
  const instance2 = {
17996
18011
  videoFit: "contain",
17997
18012
  open() {
@@ -18065,6 +18080,23 @@ var PlayBack = (props) => {
18065
18080
  });
18066
18081
  if (this.protocol == "web") {
18067
18082
  const videoEle = player.video.getVideoEl();
18083
+ videoEle.onerror = () => {
18084
+ var _a3;
18085
+ if (videoEle.src != "") {
18086
+ if (videoEle.error && videoEle.error.code == MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) {
18087
+ player.mask.text = t("hui-fang-wen-jian-bu-cun-zai");
18088
+ player.mask.visible = true;
18089
+ } else if (videoEle.error && videoEle.error.code == MediaError.MEDIA_ERR_DECODE) {
18090
+ player.mask.text = "\u89E3\u7801\u5931\u8D25";
18091
+ player.mask.visible = true;
18092
+ }
18093
+ if (isWebErrorAutoToWsBvrtc) {
18094
+ (_a3 = handle2.close) == null ? void 0 : _a3.call(handle2);
18095
+ instance2.setProtocol("ws-bvrtc");
18096
+ instance2.open();
18097
+ }
18098
+ }
18099
+ };
18068
18100
  videoEle.src = dialog_default.getPlaybackFilePath({ fileId: fileID, puid: puOption == null ? void 0 : puOption.puId }, token);
18069
18101
  videoEle.controls = false;
18070
18102
  barHandle.addEventListener("changeVolume", (data) => {
@@ -18109,6 +18141,8 @@ var PlayBack = (props) => {
18109
18141
  }
18110
18142
  });
18111
18143
  handle2.close = () => {
18144
+ videoEle.onerror = () => {
18145
+ };
18112
18146
  videoEle.src = "";
18113
18147
  markerHandle.destroy();
18114
18148
  player.close();
@@ -18152,19 +18186,47 @@ var PlayBack = (props) => {
18152
18186
  throw new Error("ws-bvrtc create offer failed.");
18153
18187
  }
18154
18188
  logger_default.info("ws-bvrtc localSDP: ", (_c = res == null ? void 0 : res.data) == null ? void 0 : _c.sdp);
18155
- const [dialog, playbackController] = yield dialog_default.getPlaybackBvrtc({
18156
- sdp: (_d = res == null ? void 0 : res.data) == null ? void 0 : _d.sdp,
18157
- id: (puOption == null ? void 0 : puOption.puId) || (puOption == null ? void 0 : puOption.nruId)
18158
- }, token);
18189
+ let dialogId = "";
18190
+ let sdp = "";
18191
+ let playbackController = {};
18192
+ try {
18193
+ const [dialog, playbackControllerTemp] = yield dialog_default.getPlaybackBvrtc({
18194
+ sdp: (_d = res == null ? void 0 : res.data) == null ? void 0 : _d.sdp,
18195
+ id: (puOption == null ? void 0 : puOption.puId) || (puOption == null ? void 0 : puOption.nruId)
18196
+ }, token);
18197
+ playbackController = playbackControllerTemp;
18198
+ dialogId = dialog.dialogId;
18199
+ sdp = dialog.sdp;
18200
+ } catch (e) {
18201
+ const openError = e;
18202
+ player.mask.text = openError.message;
18203
+ player.mask.visible = true;
18204
+ handle2.close = () => {
18205
+ var _a3;
18206
+ markerHandle.destroy();
18207
+ player.close();
18208
+ (_a3 = playbackController.close) == null ? void 0 : _a3.call(playbackController);
18209
+ hplayer == null ? void 0 : hplayer.playbackStop();
18210
+ hplayer.close();
18211
+ barHandle.destroy();
18212
+ contextIns == null ? void 0 : contextIns();
18213
+ jumpEventHandler.destory();
18214
+ handle2.close = void 0;
18215
+ handle2.pause = void 0;
18216
+ handle2.resume = void 0;
18217
+ hplayer = void 0;
18218
+ };
18219
+ return;
18220
+ }
18159
18221
  hplayer.onevent = (bCloseEvent, iResult) => {
18160
18222
  if (bCloseEvent && handle2.close) {
18161
- player.mask.text = "\u8FDE\u63A5\u610F\u5916\u5173\u95ED" + iResult;
18223
+ player.mask.text = t("lian-jie-yi-wai-guan-bi") + iResult;
18162
18224
  player.mask.visible = true;
18163
18225
  barHandle.disable();
18164
18226
  stopInterval();
18165
18227
  }
18166
18228
  };
18167
- hplayer.setRemoteSDP(dialog.dialogId, dialog.sdp);
18229
+ hplayer.setRemoteSDP(dialogId, sdp);
18168
18230
  const playbackInfo = yield playbackController.play();
18169
18231
  hplayer == null ? void 0 : hplayer.playbackStart(1);
18170
18232
  player.addEventListener("refreshInfoModal", (e) => __async(this, null, function* () {
@@ -18215,6 +18277,7 @@ var PlayBack = (props) => {
18215
18277
  (_b2 = handle2.resume) == null ? void 0 : _b2.call(handle2);
18216
18278
  }
18217
18279
  });
18280
+ barHandle.pausePlayStateChange("pause");
18218
18281
  const stopInterval = () => {
18219
18282
  if (intervalToken) {
18220
18283
  clearInterval(intervalToken);
@@ -25,7 +25,7 @@ interface IPlaybackProps extends Props {
25
25
  zIndexMenu?: number;
26
26
  displayMode?: 'playback';
27
27
  }
28
- type IPlaybackPlayType = "ws-bvrtc" | "web";
28
+ type IPlaybackPlayType = "ws-bvrtc" | "web" | "auto";
29
29
  interface IPlaybackInstance extends IComponentInstance {
30
30
  open(): Promise<void>;
31
31
  close(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@besovideo/webrtc-player",
3
- "version": "0.8.99",
3
+ "version": "0.9.1",
4
4
  "description": "@besovideo/webrtc-player desc",
5
5
  "type": "module",
6
6
  "types": "./dist/types/main.d.ts",