1- import { addScript } from '../BootstrapBlazor/modules/utility.js' ;
1+ import { addScript , registerBootstrapBlazorModule } from '../BootstrapBlazor/modules/utility.js' ;
22import Data from '../BootstrapBlazor/modules/data.js' ;
33
44export async function init ( id ) {
5- await addScript ( './_content/BootstrapBlazor.HikVision/jsVideoPlugin-1.0.0.min.js' ) ;
65 await addScript ( './_content/BootstrapBlazor.HikVision/webVideoCtrl.js' ) ;
76
87 if ( window . $ === void 0 ) {
@@ -26,6 +25,29 @@ export async function init(id) {
2625 return true ;
2726}
2827
28+ const hackJSResize = function ( ) {
29+ const originalResize = JSVideoPlugin . prototype . JS_Resize ;
30+ JSVideoPlugin . prototype . JS_Resize = function ( e , t ) {
31+ const { szId } = this . oOptions ;
32+ if ( document . getElementById ( szId ) ) {
33+ return originalResize . call ( this , e , t ) ;
34+ }
35+ }
36+ }
37+
38+ const hackJSDestroyPlugin = function ( ) {
39+ const originalDestroy = JSVideoPlugin . prototype . JS_DestroyPlugin ;
40+ JSVideoPlugin . prototype . JS_DestroyPlugin = function ( n ) {
41+ const origianlSendRequestProxy = this . oPlugin . oRequest . oRequest . sendRequest ;
42+ this . oPlugin . oRequest . oRequest . sendRequest = function ( r ) {
43+ if ( this . oWebSocket && WebSocket . OPEN === this . oWebSocket . readyState ) {
44+ return origianlSendRequestProxy . call ( this , r ) ;
45+ }
46+ }
47+ return this . oPlugin . JS_DestroyPlugin ( true ) ;
48+ }
49+ }
50+
2951const initWindow = id => {
3052 const result = { inited : null , iWndIndex : - 1 } ;
3153 WebVideoCtrl . I_InitPlugin ( {
@@ -53,7 +75,9 @@ const initWindow = id => {
5375 return new Promise ( ( resolve , reject ) => {
5476 const handler = setInterval ( ( ) => {
5577 if ( result . inited === false || ( result . inited && result . iWndIndex !== - 1 ) ) {
56- clearInterval ( handler )
78+ clearInterval ( handler ) ;
79+ hackJSResize ( ) ;
80+ hackJSDestroyPlugin ( ) ;
5781 resolve ( result ) ;
5882 }
5983 } , 16 ) ;
@@ -279,7 +303,6 @@ export function dispose(id) {
279303 logout ( id ) ;
280304 }
281305 WebVideoCtrl . I_DestroyPlugin ( ) ;
282-
283306}
284307
285308const getTagNameFirstValue = ( xmlDoc , tagName , defaultValue = '0' ) => {
0 commit comments