feat(#2954): add picture-in-picture button
parent
f6418de5c9
commit
391577367d
@ -0,0 +1,41 @@ |
||||
import { |
||||
memo, |
||||
RefObject, |
||||
} from 'react' |
||||
|
||||
import styled from 'styled-components/macro' |
||||
|
||||
import { Icon } from 'features/Icon' |
||||
|
||||
const PipWrapper = styled.div` |
||||
cursor: pointer; |
||||
margin-left: 25px; |
||||
margin-right: 25px; |
||||
margin-top: 4px; |
||||
` |
||||
|
||||
type PipProps = { |
||||
videoRef: RefObject<HTMLVideoElement>, |
||||
} |
||||
|
||||
export const PiP = memo(({ videoRef }: PipProps) => { |
||||
const togglePip = async () => { |
||||
try { |
||||
if ( |
||||
document.pictureInPictureEnabled && videoRef.current !== document.pictureInPictureElement |
||||
) { |
||||
await videoRef.current?.requestPictureInPicture() |
||||
} else { |
||||
await document.exitPictureInPicture() |
||||
} |
||||
} catch (err) { |
||||
await document.exitPictureInPicture() |
||||
} |
||||
} |
||||
|
||||
return ( |
||||
<PipWrapper> |
||||
<Icon refIcon='PiP' onClick={togglePip} /> |
||||
</PipWrapper> |
||||
) |
||||
}) |
||||
@ -0,0 +1,48 @@ |
||||
export const PiP = () => ( |
||||
<svg |
||||
xmlns='http://www.w3.org/2000/svg' |
||||
width='27' |
||||
height='27' |
||||
fill='none' |
||||
viewBox='0 0 27 27' |
||||
> |
||||
<g fill='#fff' filter='url(#filter0_d_37383_306287)'> |
||||
<path |
||||
fillRule='evenodd' |
||||
d='M3.302 3.802h19.813c1.211 0 2.202.99 2.202 2.202v8.033h-2.202V6.004H3.302v15.41h9.13v2.202h-9.13c-1.211 0-2.202-.991-2.202-2.202V6.004c0-1.211.99-2.202 2.202-2.202z' |
||||
clipRule='evenodd' |
||||
/> |
||||
<path d='M25.317 17.049a1 1 0 00-1-1h-8.899a1 1 0 00-1 1v5.567a1 1 0 001 1h8.899a1 1 0 001-1v-5.567z' /> |
||||
</g> |
||||
<defs> |
||||
<filter |
||||
id='filter0_d_37383_306287' |
||||
width='26.217' |
||||
height='21.814' |
||||
x='0.1' |
||||
y='3.802' |
||||
colorInterpolationFilters='sRGB' |
||||
filterUnits='userSpaceOnUse' |
||||
> |
||||
<feFlood floodOpacity='0' result='BackgroundImageFix' /> |
||||
<feColorMatrix |
||||
in='SourceAlpha' |
||||
result='hardAlpha' |
||||
values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0' |
||||
/> |
||||
<feOffset dy='1' /> |
||||
<feGaussianBlur stdDeviation='0.5' /> |
||||
<feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0' /> |
||||
<feBlend |
||||
in2='BackgroundImageFix' |
||||
result='effect1_dropShadow_37383_306287' |
||||
/> |
||||
<feBlend |
||||
in='SourceGraphic' |
||||
in2='effect1_dropShadow_37383_306287' |
||||
result='shape' |
||||
/> |
||||
</filter> |
||||
</defs> |
||||
</svg> |
||||
) |
||||
Loading…
Reference in new issue