1.1.0 • Published 4 years ago

react-native-clwy-video-player v1.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

react-native-clwy-video-player

A customisable, updated, React Native video player for Android and IOS, based on abbasfreestyle react-native-af-video-player and rbcorrea/react-native-rb-video-player.

This is a result of not merged pull requests and some modifications planned to be used with React Native 0.6+ version.

Demo

What did I do?

  • Android

It works good on Android. I resolved all warning and FullScreenControl disappear errors.

  • iOS

In iOS,I recommend you to use react-native-video instead.

Features

  • Fullscreen support for Android and iOS!
  • Works with react-navigation
  • Optional action button for custom use
  • Add your own logo and/or placeholder
  • Customise theme

Install

yarn add react-native-orientation-locker @sayem314/react-native-keep-awake react-native-vector-icons react-native-clwy-video-player
npx pod-install

Props

PropTypeRequiredDefaultDescription
urlstring, numberYesA URL string (or number for local) is required.
autoPlayboolNofalseAutoplays the video as soon as it's loaded
loopboolNofalseAllows the video to continuously loop
titlestringNo''Adds a title of your video at the top of the player
placeholderstringNoundefinedAdds an image placeholder while it's loading and stopped at the beginning
logostringNoundefinedAdds an image logo at the top left corner of the video
themestringNo'white'Adds an optional theme colour to the players controls
hideFullScreenControlboolNofalseThis hides the full screen control
stylenumber, objectNo{}Apply styles directly to the Video player (ignored in fullscreen mode)
resizeModestringNo'contain'Fills the whole screen at aspect ratio. contain, cover etc
rotateToFullScreenboolNofalseTapping the fullscreen button will rotate the screen. Also rotating the screen will automatically switch to fullscreen mode
fullScreenOnlyboolNofalseThis will play only in fullscreen mode
inlineOnlyboolNofalseThis hides the fullscreen button and only plays the video in inline mode
playInBackgroundboolNofalseAudio continues to play when app enters background.
playWhenInactiveboolNofalseiOS Video continues to play when control or notification center are shown.
ratenumberNo1Adjusts the speed of the video. 0 = stopped, 1.0 = normal
volumenumberNo1Adjusts the volume of the video. 0 = mute, 1.0 = full volume
onMorePressfunctionNoundefinedAdds an action button at the top right of the player. Use this callback function for your own use. e.g share link
onFullScreenfunctionNo(value) => {}Returns the fullscreen status whenever it toggles. Useful for situations like react navigation.
onTimedMetadatafunctionNoundefinedCallback when the stream receives metadata
scrollBounceboolNofalseEnables the bounce effect for the ScrollView
lockPortraitOnFsExitboolNofalseKeep Portrait mode locked after Exiting from Fullscreen mode
lockRationumberNoundefinedForce a specific ratio to the Video player. e.g. lockRatio={16 / 9}
onLoadfunctionNo(data) => {}Returns data once video is loaded
onProgressfunctionNo(progress) => {}Returns progress data
onEndfunctionNo() => {}Invoked when video finishes playing
onErrorfunctionNo(error) => {}Returns an error message argument
onPlayfunctionNo(playing) => {}Returns a boolean during playback
errorboolean, objectNotruePass in an object to Alert. See https://facebook.github.io/react-native/docs/alert.html
themeobjectNoall whitePass in an object to theme. (See example below to see the full list of available settings)
controlDurationnumberNo3Set the visibility time of the pause button and the progress bar after the video was started

Issues

Avoid adding alignItems: 'center' to the container, it can cause fullscreen mode to disappear :D

Example

import React, { useState } from 'react'
import { StyleSheet, View } from 'react-native'
import Video from 'react-native-clwy-video-player'

function VideoScreen({ route, navigation }) {  
  const [fullscreen, setFullscreen] = React.useState(false)
  React.useEffect(() => {
    navigation.setOptions({ headerShown: !fullscreen })
  }, [fullscreen, navigation])
  
  const logo = 'logo.png'
  const image = 'image.png'
  const source = '1.mp4'   

  const onFullScreen = (status) => {
    setFullscreen(status);
  };

  return (
     <View style={styles.container}>
        <Video
            url={source}
            autoPlay
            logo={logo}
            placeholder={image}
            hideFullScreenControl={false}
            onFullScreen={status => onFullScreen(status)}
            rotateToFullScreen
        />
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#fff',
    flex: 1,
    justifyContent: 'center',
  },
})

export default VideoScreen

To Do

  • Option to use custom icons
  • Support Immersive mode for Android
  • improve multiple videos fullscreen support within a ScrollView
  • investigate subtitle support
  • Support for iOS
  • Provide fullscreen support within a ScrollView
  • Customise specific components for better theming

MIT Licensed

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago