资源视频编辑组件、视频预览组件

This commit is contained in:
禺狨
2023-06-13 10:42:48 +08:00
parent 7cb408a1cb
commit 87d1fc8e01
10 changed files with 291 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
import React, { useState, useEffect } from "react";
import styles from "./index.module.less";
import closeIcon from "../../../../../assets/images/commen/close.png";
interface PropInterface {
id: number;
url: string;
open: boolean;
onCancel: () => void;
}
declare const window: any;
export const VideoPlayDialog: React.FC<PropInterface> = ({
id,
url,
open,
onCancel,
}) => {
const [loading, setLoading] = useState<boolean>(true);
useEffect(() => {
if (open && url) {
initDPlayer(url);
}
}, [id, open, url]);
const initDPlayer = (playUrl: string) => {
window.player = new window.DPlayer({
container: document.getElementById("meedu-player-container"),
autoplay: false,
video: {
url: playUrl,
},
});
window.player.on("ended", () => {
window.player && window.player.destroy();
});
};
return (
<>
{open && (
<div className={styles["play-mask"]}>
<div className={styles["play-dialog"]}>
<div
className={styles["close-button"]}
onClick={() => {
window.player && window.player.destroy();
onCancel();
}}
>
<img src={closeIcon} />
</div>
<div
className={styles["play-box"]}
id="meedu-player-container"
></div>
</div>
</div>
)}
</>
);
};