0.1.225 • Published 5 days ago

@hosseintaromi/video_player v0.1.225

Weekly downloads
-
License
ISC
Repository
-
Last release
5 days ago

Video Player · GitHub license npm version NPM Downloads stars - video_player

A video player like YouTube that allows streaming and complete customization This package lets you play videos in different formats such as m3u8, mp4, or any other form. As you noticed, this package allows you to stream; we used HLS. In terms of appearance, we tried to be entirely similar to YouTube because it is standard and popular, but you will not be limited in any way. You can customize all sections individually.

Key Features

  • Ability to stream videos or play simple videos.
  • Fully customizable appearance, inspired by YouTube.
  • Control over subtitles, dubbing, playback speed, and quality.g, playback speed and quality by default, and access to control all of these in your application.

Table of Contents

Installation

Install with npm:

$ npm i @hosseintaromi/video_player

Install with yarn:

$ yarn add @hosseintaromi/video_player

Usage

import { VideoPlayer } from "@hosseintaromi/video_player";

const App = () => {
  const playerConfig = usePlayer({
    onUpdateTime: (e) => {
      console.log("client", e);
    },
    speeds: [0.5, 1, 1.25, 1.5, 2],
    qualities: [252, 432],
    audioTracks: ["English"],
    subTitle: ["Chinese"],
    keyControl: true,
    theme: "Blue",
    locale: {
      setting_menu_change_speed_title: "انتخاب سرعت پخش",
      setting_menu_change_quality_title: "انتخاب کیفیت",
      setting_menu_quality_list_item_auto: "خودکار (بر اساس اینترنت شما)",
      setting_menu_quality_active_list: "خودکار",
      setting_menu_change_audio_track_title: "انتخاب صدا",
      setting_menu_change_subtitle: "انتخاب زیرنویس",
      setting_menu_subtitle_off: "خاموش",
    },
    autoPlay: true,
    timeForHideEl: 1000,
    type: "HLS",
  });
  return (
    <VideoPlayer
      config={playerConfig}
      src="https://cdn.bitmovin.com/content/assets/art-of-motion-dash-hls-progressive/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8"
    />
  );
};

export default App;

Config

config object type and default value

FieldTypeDefaultDescription
type"HLS" or "MP4""HLS"Specifies the type of video stream. Use 'HLS' for streaming and 'MP4' for normal videos.
loopbooleanfalseEnables video looping after it reaches the end if set to true.
autoPlaybooleanfalseStarts playing the video automatically when the player is created.
localePlayerLocaleType{}Object containing locale strings.
speedsnumber[][0.5, 0.75, 1, 1.5, 2]Array of play speeds for the video.
theme"Red" or "Blue""Blue"Sets the color theme for the player. Choose between 'Red' and 'Blue'.
timeForHideElnumber3000Time in milliseconds to automatically hide page elements.
iconsIconsType{}Object containing ReactNode for various icons.
styleStyleType{}Object containing styles for various player elements.
qualitiesnumber[][]Specify the qualities to display. If not provided, all available qualities will be shown.
audioTracksstring[][]Specify the audio tracks to display. If not provided, all available tracks will be shown.
subTitlestring[][]Specify the subtitles to display. If not provided, all available subtitles will be shown.
keyControlbooleantrueEnables key listeners for actions like play/pause (space key) or mute (M key).
thumbnailstring""Link to the thumbnail image in TTF format.
onUpdateTime(e: OnUpdateTimeType) => void-Callback function triggered on video time update.
onEnd(e: OnUpdateTimeType) => void-Callback function triggered when the video reaches the end.
onLoading(e: boolean) => void-Callback function triggered when the video is loading.
onPlayPause(e: OnUpdateTimeType) => void-Callback function triggered on play/pause events.
onUpdateBuffer(e: number) => void-Callback function triggered on buffer update.
onChangeVolume(e: OnUpdateTimeType) => void-Callback function triggered on volume change.
onChangeMute(e: boolean) => void-Callback function triggered on mute/unmute events.
onReady() => void-Callback function triggered when the player is ready.
srcstring""Source URL of the video.
loadVideo(src: string) => void-Function to load a new video source.
changeLocale(locale: PlayerLocaleType) => void-Function to change the player's locale.

style object type and default value

FieldTypeDefaultDescription
dir"rtl" or "ltr""ltr"Text direction (right-to-left or left-to-right).
iconColorstring""Color of icons.
settingTextColorstring""Color of text in settings menu.
toolbarBgstring""Background color of the toolbar.
settingBgstring""Background color of the settings menu.
settingBgHoverstring""Background color of the settings menu on hover.
rangeFrontBgstring""Background color of the progress bar.
rangeBackBgstring""Background color of the progress bar track.
bufferBgstring""Background color of the buffer bar.
settingFontSizestring""Font size of text in settings menu.
toolbarFontSizestring""Font size of text in the toolbar.
settingTitleTextColorstring""Color of the title text in settings menu.

icon object type

FieldType
settingReactNode
checkMarkReactNode
arrowReactNode
playReactNode
pauseReactNode
volumeUpReactNode
volumeDownReactNode
muteReactNode
picInPicReactNode
picOutPicReactNode
fullScreenReactNode
unFullScreenReactNode
speedReactNode
qualityReactNode
subtitleReactNode
audioTrackReactNode
autoPlayOnReactNode
autoPlayOffReactNode
jumpBackReactNode
jumpForwardReactNode
micReactNode

locale object type

FieldTypeDescription
setting_menu_change_speed_titlestringTitle for changing speed in the settings menu.
setting_menu_change_quality_titlestringTitle for changing quality in the settings menu.
setting_menu_quality_list_item_autostringLabel for the auto quality option in the settings menu.
setting_menu_quality_active_liststringLabel for the active quality option in the settings menu.
setting_menu_change_audio_track_titlestringTitle for changing audio track in the settings menu.
setting_menu_change_subtitlestringTitle for changing subtitle in the settings menu.
setting_menu_subtitle_offstringLabel for turning off subtitles in the settings menu.

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Credits

This software uses the following open source packages:

 ·  React  ·  Node.js  ·  hls.js  ·  emotion

Author

 ·  github/HosseinTaromi

 ·  linkedin/HosseinTaromi

License

Copyright © 2023, Hossein Taromi. Released under the Apache License.

0.1.224

5 days ago

0.1.223

5 days ago

0.1.225

5 days ago

0.1.222

19 days ago

0.1.221

19 days ago

0.1.218

20 days ago

0.1.220

20 days ago

0.1.217

1 month ago

0.1.216

1 month ago

0.1.213

1 month ago

0.1.215

1 month ago

0.1.214

1 month ago

0.1.212

1 month ago

0.1.211

1 month ago

0.1.208

2 months ago

0.1.210

2 months ago

0.1.204

2 months ago

0.1.198

2 months ago

0.1.199

2 months ago

0.1.202

2 months ago

0.1.203

2 months ago

0.1.197

2 months ago

0.1.196

2 months ago

0.1.192

2 months ago

0.1.194

2 months ago

0.1.193

2 months ago

0.1.195

2 months ago

0.1.190

2 months ago

0.1.191

2 months ago

0.1.187

2 months ago

0.1.186

2 months ago

0.1.189

2 months ago

0.1.188

2 months ago

0.1.183

2 months ago

0.1.185

2 months ago

0.1.184

2 months ago

0.1.170

2 months ago

0.1.179

2 months ago

0.1.176

2 months ago

0.1.175

2 months ago

0.1.178

2 months ago

0.1.177

2 months ago

0.1.172

2 months ago

0.1.171

2 months ago

0.1.174

2 months ago

0.1.173

2 months ago

0.1.181

2 months ago

0.1.180

2 months ago

0.1.182

2 months ago

0.1.169

2 months ago

0.1.168

2 months ago

0.1.167

2 months ago

0.1.165

2 months ago

0.1.164

2 months ago

0.1.166

2 months ago

0.1.158

2 months ago

0.1.157

2 months ago

0.1.159

2 months ago

0.1.154

2 months ago

0.1.153

2 months ago

0.1.156

2 months ago

0.1.155

2 months ago

0.1.152

2 months ago

0.1.161

2 months ago

0.1.160

2 months ago

0.1.163

2 months ago

0.1.162

2 months ago

0.1.149

2 months ago

0.1.150

2 months ago

0.1.151

2 months ago

0.1.147

2 months ago

0.1.146

2 months ago

0.1.148

2 months ago

0.1.143

2 months ago

0.1.142

2 months ago

0.1.145

2 months ago

0.1.144

2 months ago

0.1.139

3 months ago

0.1.136

3 months ago

0.1.135

3 months ago

0.1.138

3 months ago

0.1.137

3 months ago

0.1.132

3 months ago

0.1.134

3 months ago

0.1.133

3 months ago

0.1.141

3 months ago

0.1.140

3 months ago

0.1.131

3 months ago

0.1.129

3 months ago

0.1.128

3 months ago

0.1.127

3 months ago

0.1.126

3 months ago

0.1.130

3 months ago

0.1.118

3 months ago

0.1.117

3 months ago

0.1.119

3 months ago

0.1.114

4 months ago

0.1.113

4 months ago

0.1.116

3 months ago

0.1.115

4 months ago

0.1.125

3 months ago

0.1.124

3 months ago

0.1.121

3 months ago

0.1.120

3 months ago

0.1.123

3 months ago

0.1.110

4 months ago

0.1.112

4 months ago

0.1.107

4 months ago

0.1.109

4 months ago

0.1.96

4 months ago

0.1.97

4 months ago

0.1.98

4 months ago

0.1.99

4 months ago

0.1.90

4 months ago

0.1.91

4 months ago

0.1.93

4 months ago

0.1.95

4 months ago

0.1.85

4 months ago

0.1.86

4 months ago

0.1.88

4 months ago

0.1.89

4 months ago

0.1.84

4 months ago

0.1.103

4 months ago

0.1.104

4 months ago

0.1.82

4 months ago

0.1.83

4 months ago

0.1.80

5 months ago

0.1.81

5 months ago

0.1.78

5 months ago

0.1.77

5 months ago

0.1.75

5 months ago

0.1.74

5 months ago

0.1.73

5 months ago

0.1.72

5 months ago

0.1.62

7 months ago

0.1.61

7 months ago

0.1.58

7 months ago

0.1.57

7 months ago

0.1.56

7 months ago

0.1.55

7 months ago

0.1.54

7 months ago

0.1.53

7 months ago

0.1.52

7 months ago

0.1.51

7 months ago

0.1.50

7 months ago

0.1.49

7 months ago

0.1.48

7 months ago

0.1.47

7 months ago

0.1.46

7 months ago

0.1.44

7 months ago

0.1.43

7 months ago

0.1.42

7 months ago

0.1.41

7 months ago

0.1.40

7 months ago

0.1.39

7 months ago

0.1.38

7 months ago

0.1.36

7 months ago

0.1.35

7 months ago

0.1.34

7 months ago

0.1.33

7 months ago

0.1.32

7 months ago

0.1.29

7 months ago

0.1.28

7 months ago

0.1.27

7 months ago

0.1.25

8 months ago

0.1.23

8 months ago

0.1.22

8 months ago

0.1.21

8 months ago

0.1.20

8 months ago

0.1.19

8 months ago

0.1.18

8 months ago

0.1.17

8 months ago

0.1.16

8 months ago

0.1.15

8 months ago

0.1.14

8 months ago

0.1.13

8 months ago

0.1.12

8 months ago

0.1.11

8 months ago

0.1.10

8 months ago

0.1.9

8 months ago

0.1.8

8 months ago

0.1.7

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.0

8 months ago

0.0.9

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago