0.0.1 • Published 5 years ago

react-native-apsara-controls v0.0.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
5 years ago

react-native-media-controls

A sweet UI component to manipulate your media

mediac

Installation

yarn add react-native-media-controls

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()}
        />
      </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
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

Constants

  PLAYING,
  PAUSED,
  ENDED,

Example

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