inl-ui 0.1.138 → 0.1.139

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.
@@ -6379,7 +6379,7 @@ console.log("version:", VERSION$1);
6379
6379
  const Events = Events$1;
6380
6380
  const Endpoint = RTCEndpoint;
6381
6381
 
6382
- class WebRtcMt$1 {
6382
+ class WebRtcMt$2 {
6383
6383
  constructor(opt) {
6384
6384
  this.opt = opt;
6385
6385
  this.p_player = vue.ref();
@@ -8962,7 +8962,7 @@ const VideoPlayerV2 = vue.defineComponent({
8962
8962
  ..._prop.cameraConfig
8963
8963
  };
8964
8964
  let url = camera.webrtcTemplateMerged;
8965
- play = vue.reactive(new WebRtcMt$1({
8965
+ play = vue.reactive(new WebRtcMt$2({
8966
8966
  plays: {
8967
8967
  videoElm: `videoPlayer_${uuid}`,
8968
8968
  mediaServerAddr: camera.mediaServerPo.url,
@@ -10676,7 +10676,7 @@ const CloudVideo = vue.defineComponent({
10676
10676
  var cloudVideo = installComponent(CloudVideo, "cloud-video");
10677
10677
 
10678
10678
  const appName = "live";
10679
- class WebRtcMt {
10679
+ class WebRtcMt$1 {
10680
10680
  constructor(opt) {
10681
10681
  this.init(opt);
10682
10682
  }
@@ -10876,7 +10876,7 @@ const VideoPlayerV1 = vue.defineComponent({
10876
10876
  const init = () => {
10877
10877
  play = null;
10878
10878
  let camera = videoInfo2.value;
10879
- play = new WebRtcMt({
10879
+ play = new WebRtcMt$1({
10880
10880
  plays: {
10881
10881
  videoElm: `videoPlayer_${uuid}`,
10882
10882
  mediaServerAddr: camera.mtVideoServerAddress,
@@ -10948,6 +10948,413 @@ const VideoPlayerV1 = vue.defineComponent({
10948
10948
  });
10949
10949
  var videoPlayerV1 = installComponent(VideoPlayerV1, "video-player-v1");
10950
10950
 
10951
+ class WebRtcMt {
10952
+ constructor(opt) {
10953
+ this.opt = opt;
10954
+ this.init(opt);
10955
+ }
10956
+ opt;
10957
+ p_player;
10958
+ // 返回播放视频数据
10959
+ instance = axios__default["default"].create({
10960
+ timeout: 6e4
10961
+ });
10962
+ playerMap = /* @__PURE__ */new Map();
10963
+ streamMap = /* @__PURE__ */new Map();
10964
+ mediaServerAddrMap = /* @__PURE__ */new Map();
10965
+ config = {
10966
+ w: 100,
10967
+ h: 100,
10968
+ endpointConfig: {}
10969
+ };
10970
+ playback = false;
10971
+ // 根据参数配置组装相关url
10972
+ createRtspUrl(plays) {
10973
+ const {
10974
+ cameraIp,
10975
+ cameraRtspPort,
10976
+ cameraChannel,
10977
+ cameraStream,
10978
+ mediaServerAddr,
10979
+ addRtspProxyUrl
10980
+ } = plays;
10981
+ const stream = !this.playback ? `v${cameraIp}-${cameraRtspPort}-${cameraChannel}-${cameraStream}` : cameraStream;
10982
+ return {
10983
+ stream,
10984
+ addRtspProxyUrl,
10985
+ sdpUrl: mediaServerAddr
10986
+ };
10987
+ }
10988
+ // 初始化
10989
+ init(opt) {
10990
+ if (opt.endpointConfig) {
10991
+ this.config.endpointConfig = opt.endpointConfig;
10992
+ }
10993
+ if (opt.h) this.config.h = opt.h;
10994
+ if (opt.w) this.config.w = opt.w;
10995
+ if (opt.playback) this.playback = opt.playback;
10996
+ if (Object.prototype.toString.call(opt.plays) === "[object Object]") {
10997
+ this.p_player = this.createVideo(opt.plays);
10998
+ } else {
10999
+ for (const i of opt.plays) {
11000
+ this.createVideo(i);
11001
+ }
11002
+ }
11003
+ }
11004
+ // 拉流创建播放器
11005
+ createVideo(plays) {
11006
+ this.mediaServerAddrMap.set(plays.videoElm, plays);
11007
+ const {
11008
+ addRtspProxyUrl
11009
+ } = this.createRtspUrl(plays);
11010
+ return new Promise((resolve, reject) => {
11011
+ this.instance.get(addRtspProxyUrl).then(res => {
11012
+ if (res.data.code === 0) {
11013
+ plays.key = res.data.data?.key;
11014
+ this.startPlay(plays).then(() => {
11015
+ resolve(res.data);
11016
+ });
11017
+ } else {
11018
+ this.mediaServerAddrMap.delete(plays.videoElm);
11019
+ reject();
11020
+ this.log("err", "\u4ECE\u670D\u52A1\u7AEF\u62C9\u6D41\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
11021
+ }
11022
+ });
11023
+ });
11024
+ }
11025
+ log(type, text) {
11026
+ switch (type) {
11027
+ case "err":
11028
+ throw new Error(text);
11029
+ case "warn":
11030
+ console.warn(text);
11031
+ break;
11032
+ default:
11033
+ console.info(text);
11034
+ }
11035
+ }
11036
+ // 停止播放0
11037
+ stopPlay(id) {
11038
+ if (id) {
11039
+ let player = this.playerMap.get(id);
11040
+ if (player) {
11041
+ player.close();
11042
+ this.playerMap.delete(id);
11043
+ this.mediaServerAddrMap.delete(id);
11044
+ player = null;
11045
+ }
11046
+ } else {
11047
+ this.playerMap.forEach(item => {
11048
+ item.close();
11049
+ item = null;
11050
+ });
11051
+ this.playerMap.clear();
11052
+ this.mediaServerAddrMap.clear();
11053
+ }
11054
+ }
11055
+ // 注册事件监听
11056
+ playEvent(player, videoElm, sdpUrl) {
11057
+ player.on(Events.WEBRTC_ICE_CANDIDATE_ERROR, e => {
11058
+ this.log("err", "ICE \u534F\u5546\u51FA\u9519");
11059
+ this.rePlay(videoElm);
11060
+ });
11061
+ player.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {});
11062
+ player.on(Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, e => {
11063
+ this.log("warn", `offer anwser \u4EA4\u6362\u5931\u8D25\uFF0C\u83B7\u53D6\u89C6\u9891\u6D41\u5931\u8D25, ${e}`);
11064
+ this.rePlay(videoElm);
11065
+ });
11066
+ player.on(Events.DISCONNECTED, e => {
11067
+ this.log("warn", `\u4E8B\u4EF6\u68C0\u6D4B\u5230\u8FDE\u63A5\u65AD\u5F00${videoElm}`);
11068
+ this.rePlay(videoElm);
11069
+ });
11070
+ player.on(Events.LOST_SERVER, e => {
11071
+ this.log("warn", `\u4E8B\u4EF6\u68C0\u6D4B\u5230\u89C6\u9891\u670D\u52A1\u5668\u4E22\u5931${videoElm}`);
11072
+ this.rePlay(videoElm);
11073
+ });
11074
+ player.on(Events.WEBRTC_ON_CONNECTION_STATE_CHANGE, state => {
11075
+ if (state === "disconnected" || state === "failed") {
11076
+ this.rePlay(videoElm);
11077
+ }
11078
+ });
11079
+ }
11080
+ // 重播
11081
+ rePlay(videoElm) {
11082
+ this.stopPlay();
11083
+ setTimeout(() => {
11084
+ this.init(this.opt);
11085
+ }, 3e3);
11086
+ }
11087
+ // 播放
11088
+ play(videoElm) {
11089
+ const plays = this.mediaServerAddrMap.get(videoElm);
11090
+ const {
11091
+ sdpUrl
11092
+ } = this.createRtspUrl(plays);
11093
+ const {
11094
+ w,
11095
+ h
11096
+ } = this.config;
11097
+ const EndpointConfig = {
11098
+ element: document.getElementById(videoElm),
11099
+ debug: false,
11100
+ zlmsdpUrl: sdpUrl,
11101
+ simulcast: false,
11102
+ useCamera: false,
11103
+ audioEnable: false,
11104
+ videoEnable: true,
11105
+ recvOnly: true,
11106
+ resolution: {
11107
+ w,
11108
+ h
11109
+ }
11110
+ };
11111
+ const player = new Endpoint({
11112
+ ...Object.assign(EndpointConfig, this.config.endpointConfig)
11113
+ });
11114
+ this.playEvent(player, videoElm, sdpUrl);
11115
+ this.playerMap.set(videoElm, player);
11116
+ }
11117
+ delStream(videoElm) {
11118
+ const plays = this.mediaServerAddrMap.get(videoElm);
11119
+ if (!plays) return;
11120
+ const {
11121
+ secret,
11122
+ key,
11123
+ mediaServerUrl
11124
+ } = plays;
11125
+ const url = `${mediaServerUrl}/index/api/delStreamProxy?secret=${secret}&key=${key}`;
11126
+ this.instance.get(url);
11127
+ }
11128
+ // 开始播放
11129
+ startPlay(plays) {
11130
+ return new Promise(resolve => {
11131
+ setTimeout(() => {
11132
+ this.play(plays.videoElm);
11133
+ resolve(true);
11134
+ }, 100);
11135
+ });
11136
+ }
11137
+ }
11138
+
11139
+ function formatTime(s) {
11140
+ const minute = `${Math.floor(s / 1e3 / 60)}`.padStart(2, "0");
11141
+ const second = `${Math.floor(s / 1e3 % 60)}`.padStart(2, "0");
11142
+ return `${minute}:${second}`;
11143
+ }
11144
+
11145
+ const VideoPlayBack = vue.defineComponent({
11146
+ props: {
11147
+ start: {
11148
+ type: Number,
11149
+ required: true
11150
+ },
11151
+ stop: {
11152
+ type: Number,
11153
+ required: true
11154
+ },
11155
+ // 暂时没用
11156
+ showControl: {
11157
+ type: Boolean,
11158
+ default: false
11159
+ },
11160
+ cameraId: {
11161
+ type: String,
11162
+ required: true
11163
+ },
11164
+ cameraCode: {
11165
+ type: String,
11166
+ required: true
11167
+ },
11168
+ autoPlay: {
11169
+ type: Boolean,
11170
+ default: false
11171
+ }
11172
+ },
11173
+ setup(props, {
11174
+ expose
11175
+ }) {
11176
+ let timer;
11177
+ const videoRef = vue.ref();
11178
+ const cpnRef = vue.ref();
11179
+ const dom = vue.computed(() => `${props.cameraId + props.cameraCode}`);
11180
+ const isLoading = vue.ref(false);
11181
+ const isError = vue.ref(false);
11182
+ const player = vue.ref();
11183
+ const fullDuration = vue.computed(() => props.stop - props.start);
11184
+ core.useMouseInElement(videoRef);
11185
+ const {
11186
+ isFullscreen,
11187
+ toggle: toggleFullscreen
11188
+ } = core.useFullscreen(cpnRef);
11189
+ const isPlaying = vue.ref(false);
11190
+ const currentPlayTime = vue.ref(0);
11191
+ const currentPlayPercent = vue.ref(0);
11192
+ const startTime = vue.ref(props.start);
11193
+ const init = async () => {
11194
+ isLoading.value = true;
11195
+ isError.value = false;
11196
+ stopStream();
11197
+ const params = {
11198
+ buzKey: "playback_" + props.cameraId,
11199
+ cUuid: props.cameraId,
11200
+ startDt: startTime.value,
11201
+ drSec: parseInt(`${(props.stop - startTime.value) / 1e3}`, 0)
11202
+ };
11203
+ axios__default["default"].get(`/api/vms/v1/recorder/generatePlaybackWebrtcUrl`, {
11204
+ params,
11205
+ headers: {
11206
+ token: sessionStorage.getItem("token") || ""
11207
+ }
11208
+ }).then(async ({
11209
+ data
11210
+ }) => {
11211
+ const {
11212
+ addStreamUrl,
11213
+ stream,
11214
+ mediaServerUrl,
11215
+ secret
11216
+ } = data;
11217
+ const playUrl = mediaServerUrl + "/index/api/webrtc?app=live&stream=" + stream + "&type=play";
11218
+ const plays = {
11219
+ videoElm: dom.value,
11220
+ mediaServerAddr: playUrl,
11221
+ mediaServerUrl,
11222
+ cameraIp: "",
11223
+ cameraRtspPort: "",
11224
+ cameraChannel: "",
11225
+ cameraStream: stream,
11226
+ addRtspProxyUrl: addStreamUrl,
11227
+ secret
11228
+ };
11229
+ if (!player.value) {
11230
+ player.value = new WebRtcMt({
11231
+ plays,
11232
+ playback: true
11233
+ });
11234
+ } else {
11235
+ player.value.p_player = player.value.createVideo(plays);
11236
+ }
11237
+ player.value.p_player.then(async () => {
11238
+ const playerEvent = player.value.playerMap.get(dom.value);
11239
+ playerEvent.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {
11240
+ timer && clearInterval(timer);
11241
+ isLoading.value = false;
11242
+ isPlaying.value = true;
11243
+ timer = setInterval(() => {
11244
+ if (!isPlaying.value) return;
11245
+ const isOver = fullDuration.value - currentPlayTime.value <= 1e3;
11246
+ if (isOver && isPlaying.value) {
11247
+ currentPlayTime.value = 0;
11248
+ currentPlayPercent.value = 0;
11249
+ togglePlay();
11250
+ } else {
11251
+ currentPlayTime.value += 1e3;
11252
+ currentPlayPercent.value = Math.floor(currentPlayTime.value / fullDuration.value * 100);
11253
+ }
11254
+ }, 1e3);
11255
+ });
11256
+ }).catch(() => {
11257
+ isLoading.value = false;
11258
+ isError.value = true;
11259
+ setTimeout(() => {
11260
+ init();
11261
+ }, 5e3);
11262
+ });
11263
+ }).catch(() => {
11264
+ isLoading.value = false;
11265
+ isError.value = true;
11266
+ });
11267
+ };
11268
+ const togglePlay = () => {
11269
+ if (isPlaying.value) {
11270
+ stopStream();
11271
+ startTime.value = props.start + currentPlayTime.value;
11272
+ isPlaying.value = !isPlaying.value;
11273
+ } else {
11274
+ init();
11275
+ }
11276
+ };
11277
+ const handleSetTime = () => {
11278
+ stopStream();
11279
+ const percent = currentPlayPercent.value;
11280
+ const passedTime = Math.round(fullDuration.value * (percent / 100));
11281
+ currentPlayTime.value = passedTime;
11282
+ startTime.value = props.start + passedTime;
11283
+ init();
11284
+ };
11285
+ const stopStream = (video = dom.value) => {
11286
+ timer && clearInterval(timer);
11287
+ player.value?.delStream(video);
11288
+ player.value?.stopPlay(video);
11289
+ };
11290
+ const timeChange = () => {
11291
+ currentPlayPercent.value = 0;
11292
+ handleSetTime();
11293
+ };
11294
+ vue.watch(() => props.cameraId, (n, o) => {
11295
+ if (o) {
11296
+ currentPlayPercent.value = 0;
11297
+ currentPlayTime.value = 0;
11298
+ startTime.value = props.start;
11299
+ stopStream(`${o + props.cameraCode}`);
11300
+ init();
11301
+ }
11302
+ });
11303
+ expose({
11304
+ timeChange
11305
+ });
11306
+ vue.onMounted(() => {
11307
+ if (props.autoPlay) {
11308
+ init();
11309
+ }
11310
+ });
11311
+ vue.onBeforeUnmount(stopStream);
11312
+ return () => vue.createVNode("div", {
11313
+ "ref": cpnRef,
11314
+ "class": "video-play-back-cpn"
11315
+ }, [isError.value ? vue.createVNode("div", {
11316
+ "style": {
11317
+ width: "100%",
11318
+ textAlign: "center"
11319
+ }
11320
+ }, [vue.createVNode("img", {
11321
+ "style": {
11322
+ width: "50%"
11323
+ },
11324
+ "src": "/micro-assets/platform_web/networkAnomaly.png",
11325
+ "alt": ""
11326
+ }, null)]) : vue.createVNode(vue.Fragment, null, [vue.createVNode(vue.resolveComponent("a-spin"), {
11327
+ "spinning": isLoading.value
11328
+ }, {
11329
+ default: () => [vue.createVNode("video", {
11330
+ "ref": videoRef,
11331
+ "id": dom.value,
11332
+ "muted": true,
11333
+ "autoplay": true
11334
+ }, null)]
11335
+ }), vue.createVNode("div", {
11336
+ "class": "operation"
11337
+ }, [vue.createVNode("span", {
11338
+ "class": "btn-play",
11339
+ "onClick": togglePlay
11340
+ }, [isPlaying.value ? vue.createVNode(iconsVue.PauseCircleOutlined, null, null) : vue.createVNode(iconsVue.PlayCircleFilled, null, null)]), vue.createVNode("div", {
11341
+ "class": "progress"
11342
+ }, [vue.createVNode("span", {
11343
+ "class": "duration"
11344
+ }, [formatTime(currentPlayTime.value)]), vue.createVNode(vue.resolveComponent("a-slider"), {
11345
+ "tooltipVisible": false,
11346
+ "value": currentPlayPercent.value,
11347
+ "onUpdate:value": $event => currentPlayPercent.value = $event,
11348
+ "onAfterChange": handleSetTime
11349
+ }, null), vue.createVNode("span", {
11350
+ "class": "duration"
11351
+ }, [formatTime(fullDuration.value)])]), vue.createVNode("span", {
11352
+ "class": "btn-fullscreen",
11353
+ "onClick": toggleFullscreen
11354
+ }, [isFullscreen.value ? vue.createVNode(iconsVue.FullscreenExitOutlined, null, null) : vue.createVNode(iconsVue.FullscreenOutlined, null, null)])])])]);
11355
+ }
11356
+ });
11357
+
10951
11358
  const props$2 = {
10952
11359
  active: {
10953
11360
  type: String || Number,
@@ -14019,6 +14426,7 @@ exports.QueryFormContainer = index$4;
14019
14426
  exports.SszComment = index;
14020
14427
  exports.VideoBox = videoBox;
14021
14428
  exports.VideoBoxV2 = VideoBoxV2$1;
14429
+ exports.VideoPlayback = VideoPlayBack;
14022
14430
  exports.VideoPlayerV1 = videoPlayerV1;
14023
14431
  exports.VideoPlayerV2 = videoPlayerV2;
14024
14432
  exports.getDetailContainer = getDetailContainer;
@@ -705,6 +705,64 @@ declare const _default$7: vue.DefineComponent<{
705
705
  showInfo: boolean;
706
706
  }, {}>;
707
707
 
708
+ /**
709
+ * 视频回放
710
+ */
711
+ declare const VideoPlayBack: vue.DefineComponent<{
712
+ start: {
713
+ type: NumberConstructor;
714
+ required: true;
715
+ };
716
+ stop: {
717
+ type: NumberConstructor;
718
+ required: true;
719
+ };
720
+ showControl: {
721
+ type: BooleanConstructor;
722
+ default: boolean;
723
+ };
724
+ cameraId: {
725
+ type: StringConstructor;
726
+ required: true;
727
+ };
728
+ cameraCode: {
729
+ type: StringConstructor;
730
+ required: true;
731
+ };
732
+ autoPlay: {
733
+ type: BooleanConstructor;
734
+ default: boolean;
735
+ };
736
+ }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
737
+ start: {
738
+ type: NumberConstructor;
739
+ required: true;
740
+ };
741
+ stop: {
742
+ type: NumberConstructor;
743
+ required: true;
744
+ };
745
+ showControl: {
746
+ type: BooleanConstructor;
747
+ default: boolean;
748
+ };
749
+ cameraId: {
750
+ type: StringConstructor;
751
+ required: true;
752
+ };
753
+ cameraCode: {
754
+ type: StringConstructor;
755
+ required: true;
756
+ };
757
+ autoPlay: {
758
+ type: BooleanConstructor;
759
+ default: boolean;
760
+ };
761
+ }>>, {
762
+ showControl: boolean;
763
+ autoPlay: boolean;
764
+ }, {}>;
765
+
708
766
  declare const _default$6: vue.DefineComponent<{
709
767
  active: {
710
768
  type: PropType<string>;
@@ -1201,4 +1259,4 @@ declare const LlmChatBox: vue.DefineComponent<{
1201
1259
  withSpeech: boolean;
1202
1260
  }, {}>;
1203
1261
 
1204
- export { _default$c as AlarmVideo, _default$e as ChangeThemeSelect, _default$f as ChildLayout, _default$b as CloudVideo, _default$k as Demo, _default$1 as FontSelect, _default$6 as HeaderMenu, _default$j as IconFont, _default$5 as IconSelect, ImportModal, _default$i as Layout, _default$g as LayoutTable, LlmChatBox, _default$h as Login, _default$2 as ParamManager, ParamManagerV2, _default$3 as PeopleSelect, _default$d as PollingPlay, _default$4 as QueryFormContainer, _default as SszComment, _default$8 as VideoBox, _default$7 as VideoBoxV2, _default$9 as VideoPlayerV1, _default$a as VideoPlayerV2, getDetailContainer, getMenuDetail };
1262
+ export { _default$c as AlarmVideo, _default$e as ChangeThemeSelect, _default$f as ChildLayout, _default$b as CloudVideo, _default$k as Demo, _default$1 as FontSelect, _default$6 as HeaderMenu, _default$j as IconFont, _default$5 as IconSelect, ImportModal, _default$i as Layout, _default$g as LayoutTable, LlmChatBox, _default$h as Login, _default$2 as ParamManager, ParamManagerV2, _default$3 as PeopleSelect, _default$d as PollingPlay, _default$4 as QueryFormContainer, _default as SszComment, _default$8 as VideoBox, _default$7 as VideoBoxV2, VideoPlayBack as VideoPlayback, _default$9 as VideoPlayerV1, _default$a as VideoPlayerV2, getDetailContainer, getMenuDetail };