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

react-native-media-controller

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-media-controller

A sweet UI component to manipulate your media. Strongly typed using Typescript.

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-media-controller

This package is based on react native media player using @react-native-community/slider for react native video.

Installation

   // install package
   yarn add react-native-media-controller
   // install yarn add @react-native-community/slider, as this is a dependency of this library
   yarn add @react-native-community/slider

Usage

// Require the module
import MediaControls, { PLAYER_STATES } from "react-native-media-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
        isFullScreen={isFullScreen}
        duration={duration}
        isLoading={isLoading}
        mainColor="orange"
        onFullScreen={noop}
        onPaused={onPaused}
        onReplay={onReplay}
        onSeek={onSeek}
        onSeeking={onSeeking}
        playerState={playerState}
        progress={currentTime}
      >
        <MediaControls.Toolbar>
          <View style={styles.toolbar}>
            <Text>I'm a custom toolbar </Text>
          </View>
        </MediaControls.Toolbar>
      </MediaControls>
    </View>
  );
};

Props

PropTypeOptionalDefaultDescription
mainColorstringYesrgba(12, 83, 175, 0.9)Change custom color to the media controls
isLoadingbooleanYesfalseWhen is loading
isFullScreenbooleanYesfalseTo change icon state of fullscreen
fadeOutDelaynumberYes5000Allows to customize the delay between fade in and fade out transition
progressnumberNoCurrent time of the media player
durationnumberNoTotal duration of the media
playerStatenumberNoCould be PLAYING, PAUSED or ENDED (take a look at constants section)
onFullScreenfunctionYesTriggered when the fullscreen button is pressed. If not provided, the fullscreen icon is not displayed
onPausedfunctionNoTriggered when the play/pause button is pressed. It returns the new toggled value (PLAYING or PAUSED)
onReplayfunctionYesTriggered when the replay button is pressed
onSeekfunctionNoTriggered when the user released the slider
onBackwardfunctionYesTo Move Video Backward
onForwardfunctionYesT0 Move video forward
disableTruckbooleanYesTo disable the video controller on slider, move forward and backward
onSeekingfunctionYesTriggered when the user is interacting with the slider
showOnStartbooleanYestruecontrols the visibility of the controls during the initial render

Constants

  PLAYING,
  PAUSED,
  ENDED,

Example

Refer to the example folder to find an implementation of this project

Keywords

FAQs

Package last updated on 15 Feb 2022

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