Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netplayer

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netplayer

  • 1.6.4
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-31.82%
Maintainers
1
Weekly downloads
 
Created
Source

netplayer

Latest npm version

A simple React component that provide good looking UI video player

Usage

npm install netplayer # or yarn add netplayer
import NetPlayer from 'netplayer';

<NetPlayer
  sources={[
    {
      file: 'https://www.googleapis.com/drive/v3/files/1Q6LsjpWgPoYIs6GaD8G6lNZRM2-VJXAY?alt=media&key=AIzaSyCFwU3MAtwS2TgPPEObV-hDXexH83ae1Fs',
      label: '1080p',
    },
    {
      file: 'https://www.googleapis.com/drive/v3/files/1sKXS6VU8uUGeW8WPKDp2dXxwAJ96Tk9c?alt=media&key=AIzaSyCFwU3MAtwS2TgPPEObV-hDXexH83ae1Fs',
      label: '720p',
    },
  ]}
  subtitles={[
    {
      lang: 'en',
      language: 'English',
      file: 'https://subtitles.netpop.app/subtitles/20211116/1637057950304_国王排名 2_英语.srt',
    },
    {
      lang: 'vi',
      language: 'Tiếng Việt',
      file: 'https://subtitles.netpop.app/subtitles/20211116/1637057969656_国王排名 2_越南语.srt',
    },
  ]}
/>;

Or play around with this component

Props

NetPlayer accepts video element props and these specific props

PropTypeDescriptionDefaultRequired
sourcesSource[]An array of sources contain file, label and typenulltrue
subtitlesSubtitle[]An array of subtitles contain file, lang and languagenullfalse
hlsRefReact.MutableRefObject<Hls | null>hls.js instance refReact.createRef()false
dashRefReact.MutableRefObject<DashJS.MediaPlayerClass | null>dashjs instance refReact.createRef()false
hlsConfigHls['config']hls.js config{}false
changeSourceUrl(currentSourceUrl: string, source: Source): stringA function that modify given source url (hls only)() => nullfalse
onHlsInit(hls: Hls): voidA function that called after hls.js initialization() => nullfalse
onDashInit(dash: DashJS.MediaPlayerClass): voidA function that called after dashjs initialization() => nullfalse
onInit(videoEl: HTMLVideoElement): voidA function that called after video initialization() => nullfalse
refReact.MutableRefObject<HTMLVideoElement | null>video element refnullfalse
i18nI18nTranslationsDefault Translationsfalse
hotkeysHotkey[]Hotkeys (shortcuts)Default Hotkeysfalse
componentsComponent[]See CustomizationDefault componentsfalse
thumbnailstringThumbnails on progress bar hovernullfalse

Customization

You can customize the player by passing defined components with components props. See defined components

By passing components, the passed components will override default existing components. Allow you to customize the player how you want it to be.

Example

import NetPlayer, { TimeIndicator } from 'netplayer';

<NetPlayer
  {...props}
  components={{
    Controls: () => {
      return (
        <div className="flex items-center justify-between">
          <p>A custom Controls component</p>

          <TimeIndicator />
        </div>
      );
    },
  }}
/>;

Note: use built-in hooks and components for better customization

Override structure

NetPlayer use this default structure

To override it, simply pass your own structure as NetPlayer's children

import NetPlayer, { Controls, Player, Overlay } from 'netplayer';

<NetPlayer {...props}>
  <div>
    <div>
      <Player />
    </div>
    <div>
      <Controls />
    </div>
    <div>
      <Overlay />
    </div>
    <div>
      <p>Look I'm over here!</p>
    </div>
  </div>
</NetPlayer>;

Methods

You can access to the video element by passing ref to NetPlayer and use all its methods.

Supported formats

NetPlayer supports all video element supported formats and HLS format

Contributing

See the contribution guidelines before creating a pull request.

Other video players

FAQs

Package last updated on 22 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc