feat: dplayer
This commit is contained in:
parent
c215c6fa37
commit
8cd3f5b6d2
|
@ -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>();
|
||||
|
||||
useEffect(() => {
|
||||
if (props.video) {
|
||||
new DPlayer({
|
||||
const baseConf: DPlayerOptions = {
|
||||
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
|
||||
hls: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (props.video) {
|
||||
new DPlayer({ ...baseConf, video: { ...props.video, type: "hls" } });
|
||||
}
|
||||
}, [props.video]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user