Git Product home page Git Product logo

prathmesh28 / react-native-video-basic-controls Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 3.0 4.14 MB

Controls for the react-native-video component with full screen support.

Home Page: https://www.npmjs.com/package/react-native-video-basic-controls

License: MIT License

Shell 0.24% JavaScript 27.79% Java 9.81% Swift 0.10% Ruby 0.91% C 0.16% Objective-C 5.30% TypeScript 55.69%
react-native react-native-video react-native-video-controls react-native-video-fullscreen

react-native-video-basic-controls's Introduction

react-native-video-basic-controls

React native video controls. Controls for the react-native-video component for Android and IOS.

Features

  • Full screen support.
  • Change volume and brightness with Swipe/ Slider controls.
  • Seek forword and back button.
  • Slider customisation.
  • Swipe controls left-side brightness & right-side volume.

Installation

npm install react-native-video-basic-controls

For Brightness or Volume controls install react-native-system-setting

npm install react-native-system-setting

link react-native-system-setting

react-native link

Add permission in android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="YourPackageName"
    android:versionCode="1"
    android:versionName="1.0">

    <!-- setBrightness() & setScreenMode() & saveBrightness() -->
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />

    ...

</manifest>

Usage

// Require the module
import MediaControls, {
  PLAYER_STATES,
} from 'react-native-video-basic-controls';

const App = () => {
  const [currentTime, setCurrentTime] = useState(0);
  const [duration, setDuration] = useState(0);
  const [isFullScreen, setIsFullScreen] = useState(false);
  const [isLoading, setIsLoading] = useState(true);
  const [paused, setPaused] = useState(false);
  const [playerState, setPlayerState] = useState(PLAYER_STATES.PLAYING);

  return (
    <View style={styles.container}>
      <Video {...videoProps} />
      <MediaControls
        duration={duration}
        isLoading={isLoading}
        mainColor="orange"
        onFullScreen={noop}
        onPaused={onPaused}
        onReplay={onReplay}
        onSeek={onSeek}
        onSeeking={onSeeking}
        playerState={playerState}
        progress={currentTime}
      >
        <MediaControls.Toolbar>// ...</MediaControls.Toolbar>
      </MediaControls>
    </View>
  );
};

Refer to example for implementation of this project

Props

Main Props

Prop Type Optional Default Description
progress number No Current time of the media player
duration number No Total duration of the media
playerState number No Could be PLAYING, PAUSED or ENDED (take a look at constants section)
onPaused function No Triggered when the play/pause button is pressed. It returns the new toggled value (PLAYING or PAUSED)
onSeek function No Triggered when the user released the slider
onReplay function Yes Triggered when the replay button is pressed
onSeeking function Yes Triggered when the user is interacting with the slider

Other Props

Prop Type Optional Default Description
isLoading boolean Yes false When is loading (displays loading icon).
fadeOutDelay number Yes 5000 Allows to customize the delay between fade in and fade out transition.
onFullScreen function Yes Custom fullscreen function, triggered when the fullscreen button is pressed.
showOnStart boolean Yes true controls the visibility of the controls during the initial render.
fullScreenIconL component Yes Fullscreen icon (landscape mode).
fullScreenIconP component Yes Fullscreen icon (Portrait mode).
bufferValue number Yes Add buffer value to Slider.
onSkipFor String Yes To seek forward.
onSkipBack String Yes To seek back.
showVolume boolean Yes false Show Volume controls.
showBrightness boolean Yes false Show Brightness controls.
sliderScale number Yes 10 Scale brightness/ volume slider on press.
sliderType String Yes 'Slider' Select brightness/ volume slider type(Slider/swipe).

Style Props

Prop Type Optional Default Description
mainColor string Yes rgba(12, 83, 175, 0.9) Change custom color to the media controls
containerStyle StyleSheet Yes Apply styles to the container
toolbarStyle StyleSheet Yes Apply styles to <MediaControls.Toolbar>
iconStyle StyleSheet Yes Apply styles to fullscreen icon
sliderStyle StyleSheet Yes Apply styles to Slider
bufferColor String Yes #fff Change color of buffer view
VSliderOuterStyles StyleSheet Yes Apply styles to volume/brightness outer slider.
VSliderInnerStyles StyleSheet Yes Apply styles to volume/brightness track slider.
sliderStyle={{
  thumbStyle:{
     // ...
   },
   trackStyle:{
     // ...
   },
   containerStyle:{
     // ...
   }
}}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

react-native-video-basic-controls's People

Contributors

prathmesh28 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.