Files
silk/miniapp/dist/pages/video/player/index.js
T

1 line
5.8 KiB
JavaScript

"use strict";(wx["webpackJsonp"]=wx["webpackJsonp"]||[]).push([[90],{4534:function(e,n,a){var l=a(8774),o=a(2688),r=a(5861),i=a(9439),s=a(7294),c=a(1515),t=a(2954),d={playerPage:"index-module__playerPage___ByHCI",videoContainer:"index-module__videoContainer___OLC4T",video:"index-module__video___qAKku",videoPlaceholder:"index-module__videoPlaceholder___TefSp",placeholderIcon:"index-module__placeholderIcon___NWHor",placeholderText:"index-module__placeholderText___SGwT7",loadingOverlay:"index-module__loadingOverlay___rqYZl",loadingText:"index-module__loadingText___Ifu_q",controls:"index-module__controls___eOh8z",cameraTitle:"index-module__cameraTitle___x3eQT",formatSelector:"index-module__formatSelector___CsPOE",formatChip:"index-module__formatChip___dAbt7",formatChipActive:"index-module__formatChipActive___moz6Y",playBtn:"index-module__playBtn___E3hdI",playBtnText:"index-module__playBtnText___xX4mO",infoSection:"index-module__infoSection___bUeNm",infoTitle:"index-module__infoTitle___pCe5i",infoRow:"index-module__infoRow___rusZh",infoLabel:"index-module__infoLabel___cNNUy",infoValue:"index-module__infoValue___zwJy3",errorWrap:"index-module__errorWrap___nx392",errorIcon:"index-module__errorIcon___W473b",errorText:"index-module__errorText___D_4Z7"},_=a(9817),x=a(8106),u=a(5893),m=function(){var e=(0,t.useRouter)(),n=e.params.id?Number(e.params.id):0,a=e.params.name?decodeURIComponent(e.params.name):"\u89c6\u9891\u64ad\u653e",l=e.params.url?decodeURIComponent(e.params.url):"",m=(0,s.useState)(null),h=(0,i.Z)(m,2),f=h[0],v=h[1],p=(0,s.useState)(l),N=(0,i.Z)(p,2),j=N[0],y=N[1],b=(0,s.useState)("hls"),T=(0,i.Z)(b,2),w=T[0],C=T[1],g=(0,s.useState)(!1),k=(0,i.Z)(g,2),G=k[0],S=k[1],B=(0,s.useState)(""),I=(0,i.Z)(B,2),Z=I[0],P=I[1];(0,s.useEffect)(function(){if(l)y((0,x.Kk)(l));else{var e=function(){var e=(0,r.Z)((0,o.Z)().m(function e(){var a,l,r,i;return(0,o.Z)().w(function(e){while(1)switch(e.p=e.n){case 0:return e.p=0,e.n=1,(0,_.sp)().catch(function(){return[]});case 1:a=e.v,l=a.find(function(e){return e.id===n}),l&&(v(l),r=l.hlsUrl||l.streamUrl||l.flvUrl,r&&y((0,x.Kk)(r))),e.n=3;break;case 2:e.p=2,i=e.v,console.error("[VideoPlayer] \u83b7\u53d6\u6444\u50cf\u5934\u4fe1\u606f\u5931\u8d25:",i);case 3:return e.a(2)}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}();e()}},[n,l]);var R=function(){var e=(0,r.Z)((0,o.Z)().m(function e(){var a;return(0,o.Z)().w(function(e){while(1)switch(e.n){case 0:if(n||f){e.n=1;break}return e.a(2);case 1:S(!0),P(""),a=(0,x.Kk)("/api/v1/video/cameras/".concat(n||f.id,"/live/stream")),console.log("[VideoPlayer] \u83b7\u53d6\u64ad\u653e\u5730\u5740\u6210\u529f:",a),y(a),S(!1);case 2:return e.a(2)}},e)}));return function(){return e.apply(this,arguments)}}(),V=[{key:"hls",label:"HLS"},{key:"flv",label:"FLV"},{key:"webrtc",label:"WebRTC"}],L=!l;return(0,u.jsxs)(c.G7,{className:d.playerPage,children:[(0,u.jsxs)(c.G7,{className:d.videoContainer,children:[j?(0,u.jsx)(c.nk,{className:d.video,src:j,autoplay:!0,controls:!0,loop:!L,muted:!1,showFullscreenBtn:!0,showPlayBtn:!0,showCenterPlayBtn:!0,objectFit:"contain",onError:function(e){console.error("[VideoPlayer] \u89c6\u9891\u64ad\u653e\u9519\u8bef:",e),P("\u89c6\u9891\u64ad\u653e\u5931\u8d25")}}):(0,u.jsxs)(c.G7,{className:d.videoPlaceholder,children:[(0,u.jsx)(c.xv,{className:d.placeholderIcon,children:"\ud83d\udcf9"}),(0,u.jsx)(c.xv,{className:d.placeholderText,children:G?"\u6b63\u5728\u83b7\u53d6\u89c6\u9891\u6d41...":"\u70b9\u51fb\u4e0b\u65b9\u6309\u94ae\u5f00\u59cb\u64ad\u653e"})]}),G&&j&&(0,u.jsx)(c.G7,{className:d.loadingOverlay,children:(0,u.jsx)(c.xv,{className:d.loadingText,children:"\u52a0\u8f7d\u4e2d..."})})]}),L&&(0,u.jsxs)(c.G7,{className:d.controls,children:[(0,u.jsx)(c.xv,{className:d.cameraTitle,children:(null===f||void 0===f?void 0:f.name)||a}),(0,u.jsx)(c.G7,{className:d.formatSelector,children:V.map(function(e){return(0,u.jsx)(c.G7,{className:"".concat(d.formatChip," ").concat(w===e.key?d.formatChipActive:""),onClick:function(){return C(e.key)},children:(0,u.jsx)(c.xv,{children:e.label})},e.key)})}),(0,u.jsx)(c.G7,{className:d.playBtn,onClick:R,children:(0,u.jsx)(c.xv,{className:d.playBtnText,children:G?"\u52a0\u8f7d\u4e2d...":j?"\u91cd\u65b0\u64ad\u653e":"\u5f00\u59cb\u64ad\u653e"})})]}),f&&(0,u.jsxs)(c.G7,{className:d.infoSection,children:[(0,u.jsx)(c.xv,{className:d.infoTitle,children:"\u8bbe\u5907\u4fe1\u606f"}),(0,u.jsxs)(c.G7,{className:d.infoRow,children:[(0,u.jsx)(c.xv,{className:d.infoLabel,children:"\u7f16\u7801"}),(0,u.jsx)(c.xv,{className:d.infoValue,children:f.code})]}),(0,u.jsxs)(c.G7,{className:d.infoRow,children:[(0,u.jsx)(c.xv,{className:d.infoLabel,children:"\u72b6\u6001"}),(0,u.jsx)(c.xv,{className:d.infoValue,children:f.isOnline?"\u5728\u7ebf":"\u79bb\u7ebf"})]}),f.position&&(0,u.jsxs)(c.G7,{className:d.infoRow,children:[(0,u.jsx)(c.xv,{className:d.infoLabel,children:"\u4f4d\u7f6e"}),(0,u.jsx)(c.xv,{className:d.infoValue,children:f.position})]}),f.resolution&&(0,u.jsxs)(c.G7,{className:d.infoRow,children:[(0,u.jsx)(c.xv,{className:d.infoLabel,children:"\u5206\u8fa8\u7387"}),(0,u.jsx)(c.xv,{className:d.infoValue,children:f.resolution})]}),f.gbDeviceId&&(0,u.jsxs)(c.G7,{className:d.infoRow,children:[(0,u.jsx)(c.xv,{className:d.infoLabel,children:"\u56fd\u6807ID"}),(0,u.jsx)(c.xv,{className:d.infoValue,children:f.gbDeviceId})]})]}),Z&&(0,u.jsxs)(c.G7,{className:d.errorWrap,children:[(0,u.jsx)(c.xv,{className:d.errorIcon,children:"\u26a0\ufe0f"}),(0,u.jsx)(c.xv,{className:d.errorText,children:Z})]})]})},h=m,f={navigationBarTitleText:"\u89c6\u9891\u64ad\u653e",navigationBarBackgroundColor:"#000000",navigationBarTextStyle:"white",backgroundColor:"#000000"},v=(0,l.R4)(h,"pages/video/player/index",{root:{cn:[]}},f||{});h&&h.behaviors&&(v.behaviors=(v.behaviors||[]).concat(h.behaviors));Page(v)}},function(e){var n=function(n){return e(e.s=n)};e.O(0,[107,216,592],function(){return n(4534)});e.O()}]);