1.2.4 • Published 2 years ago

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

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

clwy-react-native-video-player

Features

  • Fullscreen support for Android and iOS!

Install

yarn add clwy-react-native-video-player react-native-orientation-locker @sayem314/react-native-keep-awake

If you use iOS

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

Example

import React, { useState } from 'react'
import { StyleSheet, View } from 'react-native'
import Video from 'clwy-react-native-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.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago