1.24.3 • Published 2 years ago

@zt-mobile/react-native-advanced-video-player v1.24.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Native Advanced Video Player

Build Status

A video player for react native with advanced controls made for react native.

  • Swipe To Seek
  • Native Brightness & Volume Controls
  • Playing videos directly from a link or from a local path
  • Supports RTMP & HLS live streaming

Peer Dependencies

This packages depends on the below packages to function properly:

  • Orientation Locker - Uses to force the user include landscape/portrait mode
  • Safe aArea - Uses to calculate fullscreen dimensions for iOS with safe area insets
  • Home Indicator - Uses to hide iOS home indicator on newer gen iPhones

Installation

Install the dependencies at the root of your React Native project.

For React Native > 0.60
$ npm install --save react-native-advanced-video-player
For React Native < 0.59
$ npm install --save react-native-advanced-video-player
$ react-native link react-native-advanced-video-player

Additional Configurations

Android

MainApplication.java
import com.rn_advanced_video_player.AdvancedVideoPackage;

@Override
protected List<ReactPackage> getPackages() {
    List<ReactPackage> packages = new PackageList(this).getPackages();
    ...
    packages.add(new AdvancedVideoPackage());
    return packages;
}

iOS

Download the icons required for the iOS side to work from the link below:- https://drive.google.com/drive/folders/1MJgxymYo5_6rjimKgKXn5OIwSkckb0C3?usp=sharing

Paste the icons into your Project.xcworkspace/Images.xcassets directory

Basic Usage

import RNVideoPlayer from "react-native-advanced-video-player";

<RNVideoPlayer
    source={"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"}
    playerStyle={{
      width: 300,
      height: 450
    }}
/>

Props

PropertyTypeDefaultDescrption
sourcestringnullURL or path to video
playerStyleobject{}Styling for the player container
fullscreenbooleanfalseDetermines whether the button should show fullscreen or not at first
swipeToSeekbooleantrueWhen true, user can swipe on the container to seek the video. NOT AVAILABLE for RTMP stream
seekBarColorstring#ffffffCustom color for seekbar
showFullscreenControlsbooleantrueShows the fullscreen and back button
showLikeButtonbooleantrueShows the like button
showShareButtonbooleantrueShows the share button
showDownloadButtonbooleantrueShows the download button

Callbacks

PropertyDescrption
onFullscreenWhen the fullscreen button is pressed
onBackPressedWhen the back button is pressed
onLikePressedWhen the like button is pressed
onSharePressedWhen the share button is pressed
onDownloadPressedWhen the download button is pressed
onControlsShowWhen the controls overlay is shown
onControlsHideWhen the controls overlay is hidden
onEnterFullsceenWhen the video player enters fullscreen mode
onLeaveFullscreenWhen the video player leaves fullscreen mode

Methods

PropertyDescrption
pausePauses the videoplayer
playPlays the videoplayer
mutePlayerMutes the videoplayer
unmutePlayerUnmutes the videoplayer
showSystemHUDMethod to switch to showing native iOS volume bar HUD*ONLY FOR iOS
killVideoPlayerKills video player instance, CALL to make sure video is stopped playing in background

Todos

  • Add more props to make it more configurable

License

MIT

Free Software, Hell Yeah!