1.6.6 • Published 8 months ago

netplayer v1.6.6

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

netplayer

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

1.6.6

8 months ago

1.6.5

8 months ago

1.6.4

10 months ago

1.6.3

10 months ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.12

1 year ago

1.4.11

2 years ago

1.4.10

2 years ago

1.4.6

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.4.9

2 years ago

1.4.8

2 years ago

1.4.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.18

2 years ago

1.2.17

2 years ago

1.2.16

2 years ago

1.2.15

2 years ago

1.2.14

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago