0.1.7 • Published 5 years ago

react-native-fullscreen-player v0.1.7

Weekly downloads
24
License
MIT
Repository
github
Last release
5 years ago

React Native Video Player

A React Native video player with a few controls. This player uses react-native-video for the video playback.

demo gif

Installation

npm install --save react-native-video-player react-native-video react-native-vector-icons
react-native link react-native-video
react-native link react-native-vector-icons

copy android java files in your project manually with res layout file and add activity in androidmanifest.xml

Props

PropDescription
videoThe video source to pass to react-native-video.
thumbnailAn Image source to use as thumbnail before the video gets loaded.
videoWidthWidth of the video to calculate the player size.
videoHeightHeight of the video to calculate the player size.
durationDuration can not always be figured out (e.g. when using hls), this can be used as fallback.
autoplayStart the video automatically.
defaultMutedStart the video muted, but allow toggling.
mutedStart the video muted and hide the mute toggle button.
controlsTimeoutTimeout when to hide the controls.
disableControlsAutoHideDisable auto hiding the controls.
disableFullscreenDisable the fullscreen button.
loopLoop the video after playback is done.
resizeModeThe video's resizeMode. defaults to contain and is passed to react-native-video.
hideControlsOnStartHides the controls on start video.
endWithThumbnailReturns to the thumbnail after the video ends.
disableSeekDisable video seeking.
pauseOnPressAutomatically pause/play when pressing the video player anywhere.
fullScreenOnLongPressAutomatically show video on fullscreen when doing a long press.
onStartCallback for when the start button is pressed.
onPlayPressCallback for when the play button is pressed.
onHideControlsCallback for when the controls are being hide.
onShowControlsCallback for when the controls are being shown.
customStylesThe player can be customized in this object, see customStyles for the options.

All other props are passed to the react-native-video component.

customStyles

  • wrapper
  • video
  • controls
  • playControl
  • controlButton
  • controlIcon
  • playIcon
  • seekBar
  • seekBarFullWidth
  • seekBarProgress
  • seekBarKnob
  • seekBarBackground
  • thumbnail
  • playButton
  • playArrow
  • videoWrapper

Methods

MethodPropsDescription
seektime: floatSeek the player to the given time.
stopStop the playback and reset back to 0:00.
pausePause the playback.
resumeResume the playback.

Future features

  • Make seek bar seekable.
  • Make player customizable.
  • Add volume control
  • Add fullscreen button
  • Add fullscreen button for android
  • Add loader

Setting up fullscreen on Android

Step 1:

Go to your android\app\src\main\java\your\package\directory folder where you can find MainActivity.java. Copy the java files from the repo's android\app\src\main\java folder and paste them there. Open those files in any editor(Android Studio recommended) and change the package names according to your project. After that, go to your MainApplication.java file and under the new MainReactPackage(), copy and paste this: new BridgePackage() and it should look similar to the code below if you do not have other packages.

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new BridgePackage()
          );
     }

Step 2:

Make a folder in your android\app\src\main\res directory and name it layout, then copy the player_fullscreen.xml from the repo's android\app\src\main\res\layout directory and paste it into your directory and then go to your AndroidManifest.xml and add this before the ending application tag:

        ```
        <activity android:name=".VideoActivity"
           android:screenOrientation="sensorLandscape"
           android:configChanges="orientation|screenSize"
        />
        ```
        
       

If you want to remove the action bar, change your theme or change the theme for your activity from the manifest

And then your fullscreen should be working and ready to go!

0.1.7

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago