mtxt-ui3 0.0.2 → 0.0.23

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.
@@ -1,4 +1,4 @@
1
- import { defineComponent, createVNode, ref, reactive, computed, inject, resolveComponent, withDirectives, vShow, provide, nextTick, watch, onBeforeUnmount, isVNode, mergeProps, onBeforeUpdate, Fragment, onMounted, onUnmounted, createTextVNode } from 'vue';
1
+ import { defineComponent, createVNode, ref, reactive, computed, inject, resolveComponent, withDirectives, vShow, provide, nextTick, watch, onBeforeUnmount, Fragment, isVNode, mergeProps, onBeforeUpdate, onMounted, onUnmounted, createTextVNode } from 'vue';
2
2
  import { useRouter } from 'vue-router';
3
3
  import { message, Form, Row, Col, FormItem, SelectOption, Input, Select, Switch, InputNumber } from 'ant-design-vue';
4
4
  import axios$2 from 'axios';
@@ -6444,11 +6444,12 @@ class RTCEndpoint extends Event$1 {
6444
6444
  const Events = Events$1;
6445
6445
  const Endpoint = RTCEndpoint;
6446
6446
 
6447
- const appName$1 = "live";
6448
6447
  class WebRtcMt$1 {
6449
6448
  constructor(opt) {
6449
+ this.opt = opt;
6450
6450
  this.init(opt);
6451
6451
  }
6452
+ opt;
6452
6453
  dom;
6453
6454
  p_player;
6454
6455
  // 返回播放视频数据
@@ -6471,11 +6472,10 @@ class WebRtcMt$1 {
6471
6472
  addRtspProxyUrl
6472
6473
  } = plays;
6473
6474
  const stream = `v${cameraIp}-${cameraRtspPort}-${cameraChannel}-${cameraStream}`;
6474
- const sdpUrl = `${mediaServerAddr}/index/api/webrtc?app=${appName$1}&stream=${stream}&type=play`;
6475
6475
  return {
6476
6476
  stream,
6477
6477
  addRtspProxyUrl,
6478
- sdpUrl: mediaServerAddr.indexOf("/index/api/webrtc") > -1 ? mediaServerAddr : sdpUrl
6478
+ sdpUrl: mediaServerAddr
6479
6479
  };
6480
6480
  }
6481
6481
  // 初始化
@@ -6493,6 +6493,7 @@ class WebRtcMt$1 {
6493
6493
  }
6494
6494
  }
6495
6495
  }
6496
+ // protected retryTime;
6496
6497
  // 拉流创建播放器
6497
6498
  createVideo(plays) {
6498
6499
  this.mediaServerAddrMap.set(plays.videoElm, plays);
@@ -6506,13 +6507,17 @@ class WebRtcMt$1 {
6506
6507
  response.json().then(res => {
6507
6508
  if (res.code === 0) {
6508
6509
  this.startPlay(plays);
6509
- resolve(res);
6510
6510
  } else {
6511
- this.mediaServerAddrMap.delete(plays.videoElm);
6512
- reject();
6513
- this.log("err", "\u4ECE\u670D\u52A1\u7AEF\u62C9\u6D41\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
6511
+ setTimeout(() => {
6512
+ this.rePlay();
6513
+ }, 3 * 60 * 1e3);
6514
6514
  }
6515
+ resolve(res);
6515
6516
  });
6517
+ }).catch(err => {
6518
+ setTimeout(() => {
6519
+ this.rePlay();
6520
+ }, 3 * 60 * 1e3);
6516
6521
  });
6517
6522
  });
6518
6523
  }
@@ -6544,10 +6549,12 @@ class WebRtcMt$1 {
6544
6549
  // 注册事件监听
6545
6550
  playEvent(player, videoElm, sdpUrl) {
6546
6551
  player.on(Events.WEBRTC_ICE_CANDIDATE_ERROR, e => {
6547
- this.log("err", "ICE \u534F\u5546\u51FA\u9519");
6552
+ this.log("warn", "ICE \u534F\u5546\u51FA\u9519");
6548
6553
  this.rePlay(videoElm);
6549
6554
  });
6550
- player.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {});
6555
+ player.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {
6556
+ this.log("warn", "\u83B7\u53D6\u5230\u4E86\u8FDC\u7AEF\u6D41\uFF0C\u53EF\u4EE5\u64AD\u653E");
6557
+ });
6551
6558
  player.on(Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, e => {
6552
6559
  this.log("warn", `offer anwser \u4EA4\u6362\u5931\u8D25\uFF0C\u83B7\u53D6\u89C6\u9891\u6D41\u5931\u8D25, ${e}`);
6553
6560
  this.rePlay(videoElm);
@@ -6568,9 +6575,10 @@ class WebRtcMt$1 {
6568
6575
  }
6569
6576
  // 重播
6570
6577
  rePlay(videoElm) {
6578
+ this.stopPlay();
6571
6579
  setTimeout(() => {
6572
- this.play(videoElm);
6573
- }, 3e3);
6580
+ this.init(this.opt);
6581
+ }, 5 * 1e3);
6574
6582
  }
6575
6583
  // 播放
6576
6584
  play(videoElm) {
@@ -6624,10 +6632,18 @@ const props$7 = {
6624
6632
  require: false,
6625
6633
  default: "fill"
6626
6634
  },
6627
- // 定时器时间
6628
- intervalTime: {
6629
- type: Number,
6630
- default: 36e5
6635
+ // token
6636
+ token: {
6637
+ type: String,
6638
+ default: ""
6639
+ },
6640
+ baseUrl: {
6641
+ type: String,
6642
+ default: ""
6643
+ },
6644
+ domId: {
6645
+ type: String,
6646
+ default: ""
6631
6647
  }
6632
6648
  };
6633
6649
  const VideoPlayerV2 = defineComponent({
@@ -6635,8 +6651,7 @@ const VideoPlayerV2 = defineComponent({
6635
6651
  emits: ["changeStream"],
6636
6652
  setup(_prop, _context) {
6637
6653
  let play;
6638
- const isMtip = ref(false);
6639
- const uuid = UUID();
6654
+ const uuid = _prop.domId;
6640
6655
  const videoFull = id => {
6641
6656
  const elm = document.getElementById(`videoPlayer_${uuid}`);
6642
6657
  if (elm.requestFullScreen) {
@@ -6646,16 +6661,15 @@ const VideoPlayerV2 = defineComponent({
6646
6661
  } else if (elm.webkitRequestFullScreen) {
6647
6662
  elm.webkitRequestFullScreen();
6648
6663
  }
6649
- setTimeout(() => {
6650
- window.onresize = () => {
6651
- _context.emit("changeStream");
6652
- };
6653
- }, 500);
6664
+ if (videoInfo2.value.brandTypeCode !== "MP4") {
6665
+ setTimeout(() => {
6666
+ window.onresize = () => {
6667
+ _context.emit("changeStream");
6668
+ };
6669
+ }, 500);
6670
+ }
6654
6671
  };
6655
- _context.expose({
6656
- videoFull
6657
- });
6658
- const videoInfo2 = ref();
6672
+ const videoInfo2 = ref({});
6659
6673
  const stopPlay = () => {
6660
6674
  if (play) {
6661
6675
  play.stopPlay(`videoPlayer_${uuid}`);
@@ -6668,56 +6682,30 @@ const VideoPlayerV2 = defineComponent({
6668
6682
  ...camera,
6669
6683
  ..._prop.cameraConfig
6670
6684
  };
6671
- const {
6672
- channel,
6673
- streamType
6674
- } = camera;
6675
6685
  let url = camera.webrtcTemplateMerged;
6676
- if (!isMtip.value && channel && streamType && url?.indexOf("${channel}") > -1 && url?.indexOf("${streamType}") > -1) {
6677
- url = url.replaceAll("${channel}", channel);
6678
- url = url.replaceAll("${streamType}", streamType);
6679
- play = new WebRtcMt$1({
6680
- plays: {
6681
- videoElm: `videoPlayer_${uuid}`,
6682
- mediaServerAddr: camera.mediaServerPo.url,
6683
- cameraUserName: camera.user,
6684
- cameraPwd: camera.pass,
6685
- cameraIp: camera.ip,
6686
- cameraRtspPort: camera.rtspPort,
6687
- cameraChannel: camera.channel,
6688
- cameraStream: camera.streamType,
6689
- addRtspProxyUrl: url
6690
- }
6691
- });
6692
- } else {
6693
- play = new WebRtcMt$1({
6694
- plays: {
6695
- videoElm: `videoPlayer_${uuid}`,
6696
- mediaServerAddr: camera.mediaServerPo.url,
6697
- cameraUserName: camera.user,
6698
- cameraPwd: camera.pass,
6699
- cameraIp: camera.ip,
6700
- cameraRtspPort: camera.rtspPort,
6701
- cameraChannel: camera.channel,
6702
- cameraStream: camera.streamType,
6703
- addRtspProxyUrl: url
6704
- }
6705
- });
6706
- }
6686
+ play = new WebRtcMt$1({
6687
+ plays: {
6688
+ videoElm: `videoPlayer_${uuid}`,
6689
+ mediaServerAddr: camera.mediaServerPo.url,
6690
+ cameraUserName: camera.user,
6691
+ cameraPwd: camera.pass,
6692
+ cameraIp: camera.ip,
6693
+ cameraRtspPort: camera.rtspPort,
6694
+ cameraChannel: camera.channel,
6695
+ cameraStream: camera.streamType,
6696
+ addRtspProxyUrl: url
6697
+ }
6698
+ });
6707
6699
  };
6708
- const stopV = id => {
6709
- const videoElement = document.getElementById(id);
6710
- if (videoElement) {
6711
- videoElement.pause();
6712
- videoElement.removeAttribute("src");
6713
- videoElement.load();
6714
- }
6700
+ const releaseUrl = ref("");
6701
+ const release = async () => {
6702
+ const res = await axios$2.get(releaseUrl.value);
6703
+ return res;
6715
6704
  };
6716
- const timer = setInterval(() => {
6717
- stopPlay();
6718
- stopV(`videoPlayer_${uuid}`);
6719
- init();
6720
- }, _prop.intervalTime);
6705
+ _context.expose({
6706
+ videoFull,
6707
+ release
6708
+ });
6721
6709
  const getVideoDetail = async camera => {
6722
6710
  let uuid2 = "";
6723
6711
  if (camera && Object.keys(camera).length && typeof camera === "object") {
@@ -6725,34 +6713,39 @@ const VideoPlayerV2 = defineComponent({
6725
6713
  } else if (camera && typeof camera === "string") {
6726
6714
  uuid2 = camera;
6727
6715
  }
6728
- const response = await fetch(`/api/vms/v1/camera/getByUuid?uuid=${uuid2}`, {
6729
- method: "GET",
6716
+ if (!uuid2) {
6717
+ return;
6718
+ }
6719
+ const detailRes = await axios$2.get(`${_prop.baseUrl}/api/vms/v1/camera/getByUuid?uuid=${uuid2}`, {
6730
6720
  headers: {
6731
- token: sessionStorage.getItem("token") || ""
6721
+ token: _prop.token || sessionStorage.getItem("token") || ""
6732
6722
  }
6733
6723
  });
6734
- const res = await response.json();
6735
- const urlResponse = await fetch(`/api/vms/v1/camera/getWebrtcUrls?uuid=${uuid2}`, {
6736
- method: "GET",
6724
+ const res = await axios$2.get(`${_prop.baseUrl}/api/vms/v1/camera/getWebrtcUrls?uuid=${uuid2}`, {
6737
6725
  headers: {
6738
- token: sessionStorage.getItem("token") || ""
6726
+ token: _prop.token || sessionStorage.getItem("token") || ""
6739
6727
  }
6740
6728
  });
6741
- const urlRes = await urlResponse.json();
6742
- if (response.status === 200 && res.data && res.data !== "") {
6743
- const camera2 = res.data;
6744
- if (urlResponse.status === 200 && urlRes.data[0] && urlRes.data[2] && urlRes.data[2] !== "uuid not found") {
6745
- isMtip.value = true;
6746
- camera2.webrtcTemplateMerged = urlRes.data[0];
6747
- camera2.mediaServerPo.url = urlRes.data[2];
6729
+ const {
6730
+ data
6731
+ } = detailRes;
6732
+ videoInfo2.value = {
6733
+ ...data.data,
6734
+ ..._prop.cameraConfig
6735
+ };
6736
+ if (res.status === 200) {
6737
+ if (res.data.data[0]) {
6738
+ videoInfo2.value.webrtcTemplateMerged = res.data.data[0];
6739
+ releaseUrl.value = res.data.data[1];
6740
+ if (videoInfo2.value.mediaServerPo) {
6741
+ videoInfo2.value.mediaServerPo.url = res.data.data[2];
6742
+ }
6743
+ init();
6748
6744
  }
6749
- videoInfo2.value = camera2;
6750
- init();
6751
6745
  }
6752
6746
  };
6753
6747
  watch([() => _prop.camera, () => _prop.cameraConfig], ([camera, cameraConfig]) => {
6754
6748
  stopPlay();
6755
- stopV(`videoPlayer_${uuid}`);
6756
6749
  getVideoDetail(camera);
6757
6750
  }, {
6758
6751
  immediate: true,
@@ -6760,15 +6753,27 @@ const VideoPlayerV2 = defineComponent({
6760
6753
  });
6761
6754
  onBeforeUnmount(() => {
6762
6755
  stopPlay();
6763
- stopV(`videoPlayer_${uuid}`);
6764
- clearInterval(timer);
6765
6756
  });
6766
- return () => createVNode("video", {
6767
- "id": `videoPlayer_${uuid}`,
6768
- "class": `videoComponent ${_prop.fill}`,
6769
- "muted": true,
6770
- "autoplay": true
6771
- }, null);
6757
+ const renderVideo = () => {
6758
+ if (videoInfo2.value.brandTypeCode === "MP4") {
6759
+ return createVNode("video", {
6760
+ "id": `videoPlayer_${uuid}`,
6761
+ "class": "videoComponent fill",
6762
+ "src": videoInfo2.value.mp4ResourcesPath,
6763
+ "autoplay": true,
6764
+ "loop": true,
6765
+ "muted": true
6766
+ }, null);
6767
+ } else {
6768
+ return createVNode("video", {
6769
+ "id": `videoPlayer_${uuid}`,
6770
+ "class": `videoComponent ${_prop.fill}`,
6771
+ "muted": true,
6772
+ "autoplay": true
6773
+ }, null);
6774
+ }
6775
+ };
6776
+ return () => createVNode(Fragment, null, [renderVideo()]);
6772
6777
  }
6773
6778
  });
6774
6779
  var videoPlayerV2 = installComponent(VideoPlayerV2, "video-player-v2");
@@ -5826,7 +5826,6 @@ class RTCEndpoint extends Event$1 {
5826
5826
  const Events = Events$1;
5827
5827
  const Endpoint = RTCEndpoint;
5828
5828
 
5829
- const appName = "live";
5830
5829
  const playOneWebRtcMt = async (uuid, domId, dom, token) => {
5831
5830
  let play;
5832
5831
  const response = await fetch(`/api/vms/v1/camera/getByUuid?uuid=${uuid}`, {
@@ -5869,8 +5868,10 @@ const playOneWebRtcMt = async (uuid, domId, dom, token) => {
5869
5868
  };
5870
5869
  class WebRtcMt {
5871
5870
  constructor(opt) {
5871
+ this.opt = opt;
5872
5872
  this.init(opt);
5873
5873
  }
5874
+ opt;
5874
5875
  dom;
5875
5876
  p_player;
5876
5877
  // 返回播放视频数据
@@ -5893,11 +5894,10 @@ class WebRtcMt {
5893
5894
  addRtspProxyUrl
5894
5895
  } = plays;
5895
5896
  const stream = `v${cameraIp}-${cameraRtspPort}-${cameraChannel}-${cameraStream}`;
5896
- const sdpUrl = `${mediaServerAddr}/index/api/webrtc?app=${appName}&stream=${stream}&type=play`;
5897
5897
  return {
5898
5898
  stream,
5899
5899
  addRtspProxyUrl,
5900
- sdpUrl: mediaServerAddr.indexOf("/index/api/webrtc") > -1 ? mediaServerAddr : sdpUrl
5900
+ sdpUrl: mediaServerAddr
5901
5901
  };
5902
5902
  }
5903
5903
  // 初始化
@@ -5915,6 +5915,7 @@ class WebRtcMt {
5915
5915
  }
5916
5916
  }
5917
5917
  }
5918
+ // protected retryTime;
5918
5919
  // 拉流创建播放器
5919
5920
  createVideo(plays) {
5920
5921
  this.mediaServerAddrMap.set(plays.videoElm, plays);
@@ -5928,13 +5929,17 @@ class WebRtcMt {
5928
5929
  response.json().then(res => {
5929
5930
  if (res.code === 0) {
5930
5931
  this.startPlay(plays);
5931
- resolve(res);
5932
5932
  } else {
5933
- this.mediaServerAddrMap.delete(plays.videoElm);
5934
- reject();
5935
- this.log("err", "\u4ECE\u670D\u52A1\u7AEF\u62C9\u6D41\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
5933
+ setTimeout(() => {
5934
+ this.rePlay();
5935
+ }, 3 * 60 * 1e3);
5936
5936
  }
5937
+ resolve(res);
5937
5938
  });
5939
+ }).catch(err => {
5940
+ setTimeout(() => {
5941
+ this.rePlay();
5942
+ }, 3 * 60 * 1e3);
5938
5943
  });
5939
5944
  });
5940
5945
  }
@@ -5966,10 +5971,12 @@ class WebRtcMt {
5966
5971
  // 注册事件监听
5967
5972
  playEvent(player, videoElm, sdpUrl) {
5968
5973
  player.on(Events.WEBRTC_ICE_CANDIDATE_ERROR, e => {
5969
- this.log("err", "ICE \u534F\u5546\u51FA\u9519");
5974
+ this.log("warn", "ICE \u534F\u5546\u51FA\u9519");
5970
5975
  this.rePlay(videoElm);
5971
5976
  });
5972
- player.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {});
5977
+ player.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {
5978
+ this.log("warn", "\u83B7\u53D6\u5230\u4E86\u8FDC\u7AEF\u6D41\uFF0C\u53EF\u4EE5\u64AD\u653E");
5979
+ });
5973
5980
  player.on(Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, e => {
5974
5981
  this.log("warn", `offer anwser \u4EA4\u6362\u5931\u8D25\uFF0C\u83B7\u53D6\u89C6\u9891\u6D41\u5931\u8D25, ${e}`);
5975
5982
  this.rePlay(videoElm);
@@ -5990,9 +5997,10 @@ class WebRtcMt {
5990
5997
  }
5991
5998
  // 重播
5992
5999
  rePlay(videoElm) {
6000
+ this.stopPlay();
5993
6001
  setTimeout(() => {
5994
- this.play(videoElm);
5995
- }, 3e3);
6002
+ this.init(this.opt);
6003
+ }, 5 * 1e3);
5996
6004
  }
5997
6005
  // 播放
5998
6006
  play(videoElm) {
@@ -5817,7 +5817,6 @@ class RTCEndpoint extends Event$1 {
5817
5817
  const Events = Events$1;
5818
5818
  const Endpoint = RTCEndpoint;
5819
5819
 
5820
- const appName = "live";
5821
5820
  const playOneWebRtcMt = async (uuid, domId, dom, token) => {
5822
5821
  let play;
5823
5822
  const response = await fetch(`/api/vms/v1/camera/getByUuid?uuid=${uuid}`, {
@@ -5860,8 +5859,10 @@ const playOneWebRtcMt = async (uuid, domId, dom, token) => {
5860
5859
  };
5861
5860
  class WebRtcMt {
5862
5861
  constructor(opt) {
5862
+ this.opt = opt;
5863
5863
  this.init(opt);
5864
5864
  }
5865
+ opt;
5865
5866
  dom;
5866
5867
  p_player;
5867
5868
  // 返回播放视频数据
@@ -5884,11 +5885,10 @@ class WebRtcMt {
5884
5885
  addRtspProxyUrl
5885
5886
  } = plays;
5886
5887
  const stream = `v${cameraIp}-${cameraRtspPort}-${cameraChannel}-${cameraStream}`;
5887
- const sdpUrl = `${mediaServerAddr}/index/api/webrtc?app=${appName}&stream=${stream}&type=play`;
5888
5888
  return {
5889
5889
  stream,
5890
5890
  addRtspProxyUrl,
5891
- sdpUrl: mediaServerAddr.indexOf("/index/api/webrtc") > -1 ? mediaServerAddr : sdpUrl
5891
+ sdpUrl: mediaServerAddr
5892
5892
  };
5893
5893
  }
5894
5894
  // 初始化
@@ -5906,6 +5906,7 @@ class WebRtcMt {
5906
5906
  }
5907
5907
  }
5908
5908
  }
5909
+ // protected retryTime;
5909
5910
  // 拉流创建播放器
5910
5911
  createVideo(plays) {
5911
5912
  this.mediaServerAddrMap.set(plays.videoElm, plays);
@@ -5919,13 +5920,17 @@ class WebRtcMt {
5919
5920
  response.json().then(res => {
5920
5921
  if (res.code === 0) {
5921
5922
  this.startPlay(plays);
5922
- resolve(res);
5923
5923
  } else {
5924
- this.mediaServerAddrMap.delete(plays.videoElm);
5925
- reject();
5926
- this.log("err", "\u4ECE\u670D\u52A1\u7AEF\u62C9\u6D41\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
5924
+ setTimeout(() => {
5925
+ this.rePlay();
5926
+ }, 3 * 60 * 1e3);
5927
5927
  }
5928
+ resolve(res);
5928
5929
  });
5930
+ }).catch(err => {
5931
+ setTimeout(() => {
5932
+ this.rePlay();
5933
+ }, 3 * 60 * 1e3);
5929
5934
  });
5930
5935
  });
5931
5936
  }
@@ -5957,10 +5962,12 @@ class WebRtcMt {
5957
5962
  // 注册事件监听
5958
5963
  playEvent(player, videoElm, sdpUrl) {
5959
5964
  player.on(Events.WEBRTC_ICE_CANDIDATE_ERROR, e => {
5960
- this.log("err", "ICE \u534F\u5546\u51FA\u9519");
5965
+ this.log("warn", "ICE \u534F\u5546\u51FA\u9519");
5961
5966
  this.rePlay(videoElm);
5962
5967
  });
5963
- player.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {});
5968
+ player.on(Events.WEBRTC_ON_REMOTE_STREAMS, e => {
5969
+ this.log("warn", "\u83B7\u53D6\u5230\u4E86\u8FDC\u7AEF\u6D41\uFF0C\u53EF\u4EE5\u64AD\u653E");
5970
+ });
5964
5971
  player.on(Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED, e => {
5965
5972
  this.log("warn", `offer anwser \u4EA4\u6362\u5931\u8D25\uFF0C\u83B7\u53D6\u89C6\u9891\u6D41\u5931\u8D25, ${e}`);
5966
5973
  this.rePlay(videoElm);
@@ -5981,9 +5988,10 @@ class WebRtcMt {
5981
5988
  }
5982
5989
  // 重播
5983
5990
  rePlay(videoElm) {
5991
+ this.stopPlay();
5984
5992
  setTimeout(() => {
5985
- this.play(videoElm);
5986
- }, 3e3);
5993
+ this.init(this.opt);
5994
+ }, 5 * 1e3);
5987
5995
  }
5988
5996
  // 播放
5989
5997
  play(videoElm) {