import { Image, Video, VideoProps } from "@tarojs/components"; // import style from "../index.module.less"; import { useEffect, useRef } from "react"; import Taro from "@tarojs/taro"; interface Props { source: string; className: string; } export const AvatarMedia = ({ source, className }: Props) => { const videoRef = useRef|null>(null); const videoContext = useRef(null); const videoId = useRef(`video-${Math.random().toString(36).substr(2, 9)}`); const videoErrorCallback = (e) => { console.log('Video error info:') console.log(e.detail) } // 处理 ios 上无法循环播放的 bug const handleOnEnded = () => { if(videoContext.current){ videoContext.current.seek(0) videoContext.current.play() } } useEffect(() => { if (videoRef.current) { videoContext.current = Taro.createVideoContext(videoId.current, this); } }, []); if (source.lastIndexOf('.mp4') > -1) { return (