Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kne/react-file",
"version": "0.1.24",
"version": "0.1.25",
"description": "提供了文件上传,文件预览,文件批量管理等功能",
"syntax": {
"esmodules": true
Expand Down
14 changes: 10 additions & 4 deletions src/components/FilePreview/VideoPreview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import React from 'react';
import React, { useEffect, useRef } from 'react';
import useRefCallback from '@kne/use-ref-callback';
import style from './style.module.scss';

const VideoPreview = ({ url, maxWidth, origin, controls = true, ...props }) => {
const VideoPreview = ({ url, maxWidth, origin, controls = true, getElement, ...props }) => {
const ref = useRef(null);
const getElementCallback = useRefCallback(getElement);
useEffect(() => {
getElementCallback(ref.current);
}, [getElementCallback]);
if (origin) {
return <video controls={controls} {...props} src={url} />;
return <video controls={controls} {...props} src={url} ref={ref} />;
}
return (
<div
Expand All @@ -13,7 +19,7 @@ const VideoPreview = ({ url, maxWidth, origin, controls = true, ...props }) => {
}}
>
<div className={style['video-inner']}>
<video controls={controls} {...props} src={url} />
<video controls={controls} {...props} src={url} ref={ref} />
</div>
</div>
);
Expand Down