1.0.0 • Published 8 months ago

rc-dplayer v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

rc-dplayer

This is a wrapper of DPlyer;

It contains hls.js and flv.js,you can play your video directly.

As of version 1.0.0, the HLS protocol supports HEVC encoding.

Since Chrome 107 version supports HEVC hardware decoding function, this project upgrades hls.js and realizes HLS + HEVC video stream playback based on hardware decoding capability

Install

npm

npm install rc-dplayer

pnpm

pnpm add rc-dplayer

Examples

import { Player as RcDPlayer } from "rc-dplayer";

const App = () => {
  return (
    <RcDPlayer
      src="/test.mp4"
      options={{
        autoplay: true,
      }}
      onLoad={(dp) => {
        console.log("DPlayer instance", dp);
      }}
      onError={(event) => {
        console.error("error", event);
      }}
    />
  );
};

Props

nametypedescriptiondefault
srcstringVideo source .-
mseTypeMseTypeMSE type .MseType.default
autoLoadbooleanAuto load video when it`s true and src exits.true
optionsDPlayerOptionsThe other options of DPlayer .-
customControllersCustomController[]Custom controller-
onLoad(dp: DPlayer) => voidCallback of player loaded-

Events

Support HTML media events and DPlayer events.

// React DPlayer Events
export interface DPlayerEventsProps {
  onScreenshot?: (blobUrl: string) => void;
  onThumbnailsShow?: () => void;
  onThumbnailsHide?: () => void;
  onDanmakuShow?: () => void;
  onDanmakuHide?: () => void;
  onDanmakuClear?: () => void;
  onDanmakuLoaded?: () => void;
  onDanmakuSend?: () => void;
  onDanmakuOpacity?: () => void;
  onContextmenuShow?: () => void;
  onContextmenuHide?: () => void;
  onNoticeShow?: () => void;
  onNoticeHide?: () => void;
  onQualityStart?: () => void;
  onQualityEnd?: () => void;
  onDestroy?: () => void;
  onFullscreen?: () => void;
  onFullscreenCancel?: () => void;
  onSubtitleShow?: () => void;
  onSubtitleHide?: () => void;
  onSubtitleChange?: () => void;
}

Interface

export enum MseType {
  hls = "m3u8",
  flv = "flv",
  default = "default",
}
type ControllerPosition = "left" | "right";

export interface CustomController {
  key: Key;
  position: ControllerPosition;
  component: ReactNode;
  onClick?: (event: ReactMouseEvent<HTMLDivElement, MouseEvent>) => void;
}

Ref methods

nametypedescription
load(url?: string, mseType?: MseType) => DPlayerLoad video by yourself .

License

rc-dplayer is released under the MIT license.

1.0.0

8 months ago

0.1.0

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago