1.1.1 • Published 6 years ago

react-native-media-controls-asap v1.1.1

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
6 years ago

react-native-media-controls

A sweet UI component to manipulate your media

mediac

Installation

yarn add react-native-media-controls-asap

Usage

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

  render() {
    return (
      <View style={styles.container}>
        <Video
          onEnd={this.onEnd}
          onLoad={this.onLoad}
          onLoadStart={this.onLoadStart}
          onProgress={this.onProgress}
          paused={this.state.paused}
          ref={videoPlayer => (this.videoPlayer = videoPlayer)}
          resizeMode="cover"
          source={{ uri: 'https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4' }}
          style={styles.mediaPlayer}
          volume={0.0}
        />
        <MediaControls
          duration={this.state.duration}
          isLoading={this.state.isLoading}
          mainColor="orange"
          onFullScreen={this.onFullScreen}
          onPaused={this.onPaused}
          onReplay={this.onReplay}
          onSeek={this.onSeek}
          playerState={this.state.playerState}
          progress={this.state.currentTime}
          toolbar={this.renderToolbar()}
          // playIcon={}
          // pauseIcon={}
          // replayIcon={}
          // controlsColor={}
          // controlsStyle={}
          // iconStyle={}
        />
      </View>
    );
  }

Props

PropTypeOptionalDefaultDescription
toolbarnodeYesAdd a custom view on the top of the controls
mainColorstringYesrgba(12, 83, 175, 0.9)Change custom color to the media controls (progress bar)
isLoadingboolYesfalseWhen is loading
isFullScreenboolYesfalseTo change icon state of fullscreen
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
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
onSeekingfunctionYesTriggered when the user is interacting with the slider
playIconstringYesCould pass a require('image path') or {uri='image path'} to show as the play icon
pauseIconstringYesCould pass a require('image path') or {uri='image path'} to show as the pause icon
replayIconstringYesCould pass a require('image path') or {uri='image path'} to show as the replay icon
controlsColorstringYesChange custom background color to the media controls (play, pause and replay button)
controlsStyleobjectYesChange custom style to the media controls (play, pause and replay button)
iconStyleobjectYesChange custom style to the media controls icon (play, pause and replay)

Constants

  PLAYING,
  PAUSED,
  ENDED,

Example

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