feat: dplayer

This commit is contained in:
mozzie 2023-03-02 16:45:05 +08:00
parent c215c6fa37
commit 8cd3f5b6d2

View File

@ -1,6 +1,6 @@
import { useEffect, useRef } from "react";
import DPlayer from "dplayer";
import './index.less'
import DPlayer, { DPlayerOptions } from "dplayer";
import "./index.less";
interface IProps {
video: {
@ -12,23 +12,19 @@ interface IProps {
function Player(props: IProps) {
const playerRef = useRef<any>();
const baseConf: DPlayerOptions = {
container: playerRef.current,
preload: "auto",
playbackSpeed: [0.5, 0.75, 1, 1.25, 1.5, 2],
screenshot: true,
pluginOptions: {
hls: {},
},
};
useEffect(() => {
if (props.video) {
new DPlayer({
container: playerRef.current,
video: {
...props.video,
type: "hls",
},
preload: "auto",
playbackSpeed: [0.5, 0.75, 1, 1.25, 1.5, 2],
screenshot: true,
pluginOptions: {
hls: {
// hls config
},
},
});
new DPlayer({ ...baseConf, video: { ...props.video, type: "hls" } });
}
}, [props.video]);