fix(#in178): pip fix

fix($in178): min fix

fix(#in178): attr check add

fix(#in178): auto pip conditions fixed

fix(#178): auto pip min fix
keep-around/44e70269ba4e4c3ea8c912424bbb3a0e479f07f4
Farber Denis 3 years ago
parent 66ddaf141e
commit 5f47bbce1b
  1. 18
      src/components/PictureInPicture/PiP.tsx
  2. 1
      src/features/MatchPage/index.tsx
  3. 2
      src/features/StreamPlayer/components/Controls/Components/ControlsWeb/index.tsx

@ -1,6 +1,7 @@
import { import {
memo, memo,
RefObject, RefObject,
useEffect,
} from 'react' } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
@ -15,10 +16,11 @@ const PipWrapper = styled.div`
` `
type PipProps = { type PipProps = {
isPlaying: boolean,
videoRef: RefObject<HTMLVideoElement>, videoRef: RefObject<HTMLVideoElement>,
} }
export const PiP = memo(({ videoRef }: PipProps) => { export const PiP = memo(({ isPlaying, videoRef }: PipProps) => {
const togglePip = async () => { const togglePip = async () => {
try { try {
if ( if (
@ -33,6 +35,20 @@ export const PiP = memo(({ videoRef }: PipProps) => {
} }
} }
useEffect(() => {
window.addEventListener('visibilitychange', async () => {
if (
document.hidden === true
&& document.pictureInPictureEnabled
&& videoRef.current !== document.pictureInPictureElement
&& videoRef.current?.hidden === false
&& isPlaying
) {
await videoRef.current?.requestPictureInPicture()
}
})
}, [videoRef, isPlaying])
return ( return (
<PipWrapper> <PipWrapper>
<Icon refIcon='PiP' onClick={togglePip} /> <Icon refIcon='PiP' onClick={togglePip} />

@ -82,6 +82,7 @@ const MatchPageComponent = () => {
const sportName = history.location.pathname.split('/')[1] const sportName = history.location.pathname.split('/')[1]
history.push(`/${sportName}/tournaments/${profile.tournament.id}`) history.push(`/${sportName}/tournaments/${profile.tournament.id}`)
} }
return ( return (
<PageWrapper isIOS={isIOS}> <PageWrapper isIOS={isIOS}>
<ProfileHeader color='#2B2A28' height={client.name === 'facr' ? 5 : 4.5} /> <ProfileHeader color='#2B2A28' height={client.name === 'facr' ? 5 : 4.5} />

@ -114,7 +114,7 @@ export const ControlsWeb = (controlsProps: { props: ControlsPropsExtended }) =>
)} )}
<ChromeCast src={src} /> <ChromeCast src={src} />
{document.pictureInPictureEnabled && ( {document.pictureInPictureEnabled && (
<PiP videoRef={videoRef} /> <PiP videoRef={videoRef} isPlaying={playing} />
)} )}
<Settings <Settings
onSelect={onQualitySelect} onSelect={onQualitySelect}

Loading…
Cancel
Save