Skip to content

Commit

Permalink
Merge pull request #1895 from blockscout/fe-1872
Browse files Browse the repository at this point in the history
remove video autoplay from lists
  • Loading branch information
isstuev authored May 8, 2024
2 parents 3d60059 + 4cc4e43 commit cc97093
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions ui/address/tokens/NFTItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const NFTItem = ({ token, value, isLoading, withTokenLink, ...tokenInstance }: P
animationUrl={ tokenInstance?.animation_url ?? null }
imageUrl={ tokenInstance?.image_url ?? null }
isLoading={ isLoading }
autoplayVideo={ false }
/>
</Link>
<Flex justifyContent="space-between" w="100%" flexWrap="wrap">
Expand Down
5 changes: 3 additions & 2 deletions ui/shared/nft/NftMedia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ interface Props {
className?: string;
isLoading?: boolean;
withFullscreen?: boolean;
autoplayVideo?: boolean;
}

const NftMedia = ({ imageUrl, animationUrl, className, isLoading, withFullscreen }: Props) => {
const NftMedia = ({ imageUrl, animationUrl, className, isLoading, withFullscreen, autoplayVideo }: Props) => {
const [ isMediaLoading, setIsMediaLoading ] = React.useState(true);
const [ isLoadingError, setIsLoadingError ] = React.useState(false);

Expand Down Expand Up @@ -71,7 +72,7 @@ const NftMedia = ({ imageUrl, animationUrl, className, isLoading, withFullscreen

switch (type) {
case 'video':
return <NftVideo { ...props }/>;
return <NftVideo { ...props } autoPlay={ autoplayVideo }/>;
case 'html':
return <NftHtml { ...props }/>;
case 'image':
Expand Down
4 changes: 3 additions & 1 deletion ui/shared/nft/NftVideo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import { mediaStyleProps, videoPlayProps } from './utils';

interface Props {
src: string;
autoPlay?: boolean;
onLoad: () => void;
onError: () => void;
onClick?: () => void;
}

const NftVideo = ({ src, onLoad, onError, onClick }: Props) => {
const NftVideo = ({ src, autoPlay = true, onLoad, onError, onClick }: Props) => {
return (
<chakra.video
{ ...videoPlayProps }
autoPlay={ autoPlay }
src={ src }
onCanPlayThrough={ onLoad }
onError={ onError }
Expand Down
1 change: 1 addition & 0 deletions ui/shared/nft/NftVideoFullscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const NftVideoFullscreen = ({ src, isOpen, onClose }: Props) => {
src={ src }
maxH="90vh"
maxW="90vw"
autoPlay={ true }
/>
</NftMediaFullscreenModal>
);
Expand Down
1 change: 0 additions & 1 deletion ui/shared/nft/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const mediaStyleProps = {
};

export const videoPlayProps = {
autoPlay: true,
disablePictureInPicture: true,
loop: true,
muted: true,
Expand Down
1 change: 1 addition & 0 deletions ui/token/TokenInventoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const TokenInventoryItem = ({ item, token, isLoading }: Props) => {
animationUrl={ item.animation_url }
imageUrl={ item.image_url }
isLoading={ isLoading }
autoplayVideo={ false }
/>
);

Expand Down

0 comments on commit cc97093

Please sign in to comment.