Skip to content

Commit e77f674

Browse files
do not initialize a new stream player if the screen is resized in fullscreen mode
1 parent 0be1dba commit e77f674

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/helper/isFullscreen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const isFullscreen = () => {
2+
return !!(
3+
document.fullscreenElement ||
4+
(document as any).webkitFullscreenElement ||
5+
(document as any).mozFullScreenElement ||
6+
(document as any).msFullscreenElement
7+
)
8+
}

src/hooks/useUpdatePlayerHeight.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { useEffect } from 'react'
2+
import { isFullscreen } from '../helper/isFullscreen'
23

34
export const useUpdatePlayerHeight = (
45
containerRef: React.MutableRefObject<HTMLDivElement | null>,
56
setHeight: (value: React.SetStateAction<number>) => void
67
) => {
78
useEffect(() => {
89
const updateHeight = () => {
10+
if (isFullscreen()) {
11+
return
12+
}
13+
914
if (containerRef.current) {
1015
const width = containerRef.current.offsetWidth
1116
setHeight(Math.round((width * 9) / 16))

0 commit comments

Comments
 (0)