Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
df293ac6
Commit
df293ac6
authored
Sep 22, 2023
by
李纪文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改
parent
2ec3b55c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
30 deletions
+19
-30
index.jsx
packages/base-components/VmsVideo/src/index.jsx
+19
-30
No files found.
packages/base-components/VmsVideo/src/index.jsx
View file @
df293ac6
...
@@ -44,8 +44,6 @@ const Video = (props, ref) => {
...
@@ -44,8 +44,6 @@ const Video = (props, ref) => {
const
_video
=
useRef
(
null
);
const
_video
=
useRef
(
null
);
const
Players
=
useRef
(
null
);
const
Players
=
useRef
(
null
);
const
refs
=
useRef
(
null
);
const
refs
=
useRef
(
null
);
const
[
width
,
setWidth
]
=
useState
(
0
);
const
[
height
,
setHeight
]
=
useState
(
0
);
let
PlayersA
=
''
;
let
PlayersA
=
''
;
const
{
VideoInfo
,
JessibucaObj
,
gateway
}
=
props
;
const
{
VideoInfo
,
JessibucaObj
,
gateway
}
=
props
;
let
baseUrl
=
`ws://
${
window
.
location
.
host
}
/jessica`
;
let
baseUrl
=
`ws://
${
window
.
location
.
host
}
/jessica`
;
...
@@ -57,11 +55,7 @@ const Video = (props, ref) => {
...
@@ -57,11 +55,7 @@ const Video = (props, ref) => {
fullUrl
:
''
,
fullUrl
:
''
,
key
:
`摄像头`
,
key
:
`摄像头`
,
};
};
useLayoutEffect
(()
=>
{
console
.
log
(
refs
.
current
.
offsetWidth
,
refs
.
current
.
offsetHeight
,
'宽高'
);
setWidth
(
refs
.
current
.
offsetWidth
);
setHeight
(
refs
.
current
.
offsetHeight
);
},
[]);
const
getToken
=
async
()
=>
{
const
getToken
=
async
()
=>
{
axios
axios
.
post
(
.
post
(
...
@@ -75,7 +69,6 @@ const Video = (props, ref) => {
...
@@ -75,7 +69,6 @@ const Video = (props, ref) => {
)
)
.
then
(
function
(
response
)
{
.
then
(
function
(
response
)
{
let
accessToken
=
response
.
data
.
data
.
accessToken
;
let
accessToken
=
response
.
data
.
data
.
accessToken
;
PlayersA
=
new
EZUIKit
.
EZUIKitPlayer
({
PlayersA
=
new
EZUIKit
.
EZUIKitPlayer
({
id
:
keyID
,
// 视频容器ID
id
:
keyID
,
// 视频容器ID
accessToken
:
accessToken
,
accessToken
:
accessToken
,
...
@@ -98,33 +91,37 @@ const Video = (props, ref) => {
...
@@ -98,33 +91,37 @@ const Video = (props, ref) => {
});
});
};
};
const
resizeUpdate
=
(
e
)
=>
{
// 通过事件对象获取浏览器窗口的高度
// PlayersA?.stop?.()
console
.
log
(
PlayersA
,
'视频对象11111111111111111111111111111111111111111111111'
);
PlayersA
.
stop
();
getToken
();
};
if
(
VideoInfo
.
protocol
!=
'萤石EZOPEN'
)
{
if
(
VideoInfo
.
protocol
!=
'萤石EZOPEN'
)
{
useImperativeHandle
(
ref
,
()
=>
{
useImperativeHandle
(
ref
,
()
=>
{
// changeVal 就是暴露给父组件的方法, newVal是父组件传递的参数
// changeVal 就是暴露给父组件的方法, newVal是父组件传递的参数
return
_video
.
current
.
jessibuca
;
// _video&& _video.current&&_video.current.jessibuca
return
_video
.
current
.
jessibuca
;
// _video&& _video.current&&_video.current.jessibuca
});
});
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
VideoInfo
.
protocol
!=
'萤石EZOPEN'
)
{
if
(
VideoInfo
.
protocol
!=
'萤石EZOPEN'
)
{
}
else
{
}
else
{
getToken
();
getToken
();
}
}
// 页面刚加载完成后获取浏览器窗口的大小
// 页面变化时获取浏览器窗口的大小
const
resizeObserver
=
new
ResizeObserver
((
entries
)
=>
{
window
.
addEventListener
(
'resize'
,
resizeUpdate
);
PlayersA
&&
PlayersA
.
reSize
(
refs
?.
current
?.
offsetWidth
||
952
,
refs
?.
current
?.
offsetHeight
||
500
);
});
refs
.
current
&&
resizeObserver
.
observe
(
refs
.
current
);
return
()
=>
{
return
()
=>
{
// 组件销毁时移除监听事件
try
{
window
.
removeEventListener
(
'resize'
,
resizeUpdate
);
// eslint-disable-next-line react-hooks/exhaustive-deps
resizeObserver
.
unobserve
(
refs
?.
current
);
try
{
PlayersA
&&
PlayersA
.
stop
();
PlayersA
&&
PlayersA
.
destroy
();
}
catch
(
e
)
{}
// eslint-disable-next-line react-hooks/exhaustive-deps
PlayersA
=
null
;
if
(
document
.
getElementById
(
`
${
keyID
}
`
))
document
.
getElementById
(
`
${
keyID
}
`
).
innerHTML
=
''
;
}
catch
(
e
)
{}
};
};
},
[]);
},
[]);
...
@@ -155,18 +152,10 @@ const Video = (props, ref) => {
...
@@ -155,18 +152,10 @@ const Video = (props, ref) => {
};
};
}
}
useEffect
(()
=>
{
return
()
=>
{
try
{
PlayersA
&&
PlayersA
.
stop
();
}
catch
(
e
)
{}
};
},
[]);
return
(
return
(
<
div
ref=
{
refs
}
className=
{
style
.
app
}
>
<
div
ref=
{
refs
}
className=
{
style
.
app
}
>
{
VideoInfo
.
protocol
==
'萤石EZOPEN'
?
(
{
VideoInfo
.
protocol
==
'萤石EZOPEN'
?
(
<
div
id=
{
keyID
}
></
div
>
<
div
id=
{
keyID
}
/
>
)
:
(
)
:
(
<
App1
{
...
{
VideoInfo
:
_VideoInfo
,
JessibucaObj
:
JessibucaObj
}}
ref=
{
_video
}
/>
<
App1
{
...
{
VideoInfo
:
_VideoInfo
,
JessibucaObj
:
JessibucaObj
}}
ref=
{
_video
}
/>
)
}
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment