1.0.4 • Published 1 month ago

r-lite-player v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

ReactLitePlayer player is a minimalistic video player aimed to offer simple usage with the least of features you need for your project, while making everything simple the library offers customization and call-back functions that you may want.

Frame 2 (2)

npm i react-lite-player

usage

import { Video } from "r-lite-player";

function App() {
  return (
    <>
      <Video
        width={1000}
        url="your video url"
        subtitleUrl="your subti url" //optionl
      />
    </>
  );
}
Props
propDescriptionDefault
urlYour video URLNo default.
subtitleUrlYour subtitle file's URLNo default.
subtitleLanguageSubtitle languageEnglish
subtitleColorSubtitle text color#ffff
posterPoster image URLNo default.
enableNextButtonShow next and previous buttonsFalse
onPlayEvent triggered upon the commencement of playback
onPauseEvent triggered when the video pausesNo default.
nextFunction called when pressing the next buttonUndefined
previousFunction called when pressing the previous buttonUndefined
widthVideo width100%
heightVideo heightAuto
wrapperBackgroundVideo container background#333
errorMessageError message displayed when an error occursSomething went wrong.
customErrorMessageComponentCustom error component; having one overrides the defaultNull
loopAllow video to play in a loopFalse
hideVideoWhenErrorHide the video when an error occursTrue (recommended)
crossOriginVideo cross-origin propertyAnonymous
subtitleBackgroundSubtitle background#000000a3
bufferedIndicatorBackgroundBackground of the loaded-buffer progressUndefined
videoProgressBackgroundVideo progress background#ffff
autoPlayPlay the video immediately after loadingFalse
playerProgressBarContainerProgress bar container#9d9d9d34
customControlsAreahis area is reserved for any elements you may want to add to the bottom-left side of the controllers, such as a subtitles drop-down or settings drop-down for the player. Just anything you may want to add to the playernull

Video Ref

To allow full customization and control over the video, the video forwards its ref and some methods that you can access using the useVideoRef hook those methods are

MethodUse case
togglePlayplay and pause the video
toggleCaptionsshow and hide the subtitle component
togglePictureModetoggle picture mode
toggleMuteMute or unmute the video
toggleFullscreenenter and exit full screen

The video can also but accessed from the ref but calling ref.current.video(the name ref depends on how you name your variable)

Example use case

import { Video, useVideoRef } from "react-lite-player";

function App() {
  const video = useVideoRef();

  function togglePlay() {
    video.current?.togglePlay();
  }

  return (
    <div>
      <button onClick={togglePlay}>toggle play</button>{" "}
      {/*//control the player from your component directly using the forwarded ref */}
      <Video ref={video} url={"url"} />
    </div>
  );
}

export default App;

If you find this library useful consider linking it on GitHub, or maybe why not contribute to it 😌😌