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 { memo, useEffect, useState } from 'react'
import { ViewStyle } from 'react-native' import { ViewStyle } from 'react-native'
import Video from 'react-native-video' import Video from 'react-native-video'
@ -17,22 +18,25 @@ const VideoBox = ({ url, poster, style, ...videoProps }: Props) => {
setPaused(!Boolean(url)) setPaused(!Boolean(url))
}, [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 ( return (
// 当 url 变化时通过 key 强制重载,确保自动播放生效 // 当 url 变化时通过 key 强制重载,确保自动播放生效
<Video // <Video
key={url ?? 'no-url'} // key={url ?? 'no-url'}
source={{ uri: url }} // source={{ uri: url }}
poster={poster} // poster={poster}
repeat // repeat
viewType={0} // viewType={0}
controls={false} // controls={false}
resizeMode="cover" // resizeMode="cover"
volume={0} // volume={0}
muted // muted
paused={paused} // paused={paused}
style={style as any} // style={style as any}
{...videoProps} // {...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" /> {/* <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" />} {isSelected && <Block className="absolute inset-[0px] border-[3px] border-accent" />}