This commit is contained in:
imeepos 2025-12-25 19:51:54 +08:00
parent cd9ed0a734
commit f4c561b478
2 changed files with 20 additions and 16 deletions

View File

@ -1,3 +1,4 @@
import { Image } from 'expo-image'
import { memo, useEffect, useState } from 'react'
import { ViewStyle } from 'react-native'
import Video from 'react-native-video'
@ -17,22 +18,25 @@ const VideoBox = ({ url, poster, style, ...videoProps }: Props) => {
setPaused(!Boolean(url))
}, [url])
const createUrl = (url: string)=>`https://modal-dev.bowong.cc/api/custom/video/converter/${encodeURI(url)}?options=compression_level=3,quality=70,loop=true,resolution=120x120,fps=24`
return (
// 当 url 变化时通过 key 强制重载,确保自动播放生效
<Video
key={url ?? 'no-url'}
source={{ uri: url }}
poster={poster}
repeat
viewType={0}
controls={false}
resizeMode="cover"
volume={0}
muted
paused={paused}
style={style as any}
{...videoProps}
/>
// <Video
// key={url ?? 'no-url'}
// source={{ uri: url }}
// poster={poster}
// repeat
// viewType={0}
// controls={false}
// resizeMode="cover"
// volume={0}
// muted
// paused={paused}
// style={style as any}
// {...videoProps}
// />
<Image source={{ uri: url ? createUrl(url) : '' }} style={style as any} />
)
}

View File

@ -240,9 +240,9 @@ const GridItem = memo<GridItemProps>(function GridItem({ item, isSelected, itemW
) : (
<Img src={item.poster} className="h-full w-full" />
)} */}
<Img src={item.poster} className="h-full w-full" />
{/* <Img src={item.poster} className="h-full w-full" /> */}
{/* <VideoBox url={item.url} style={{ height: itemWidth, width: itemWidth }} /> */}
<VideoBox url={item.url} style={{ height: itemWidth, width: itemWidth }} />
{isSelected && <Block className="absolute inset-[0px] border-[3px] border-accent" />}