我的需要是获取该视频文件的持续时间或时间长度。所以我做了 console.log(videoFile.duration)
,但是它的显示undefined
&为什么它显示未定义?那么如何在React js 中获取视频时长...
const VideoList = ({ videoFile }) => {
console.log(videoFile.duration);
// output ==> undefined
return (
<div className="relative">
<video src={videoFile} className="w-full pb-2 sm:w-32 sm:pb-0 rounded mr-2" />
<span className="absolute bottom-1 right-3 bg-black/60 text-white rounded px-1.5">0:00</span>
</div>
);
}
export default VideoList;
Run Code Online (Sandbox Code Playgroud)