2.0.19 • Published 4 years ago

react-native-ivideo-player v2.0.19

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

react-native-ivideo-player

react-native-ivideo-player is a react-native-video based video player component. React Native > 0.40.0 is required. This is a fork of react-native-ivideo.

Currently, the performance is not tested on IOS.

Features:

  • Basic playback features, friendly interface, progress control, evolving animation, and simple style.
  • Fine-grained optimization, the UI thread can maintain 60 FPS during playback, and the JS thread can maintain 60 ~ 55 FPS.
  • Provides full-screen playback.
  • Supports formats such as MP4, M4A, FMP4, WebM, MKV, MP3, Ogg, WAV, MPEG-TS, MPEG-PS, FLV and ADTS (AAC).
  • Support DASH, HlS and SmoothStreaming adaptive streaming.

Basic playback function, schedule control.

npm.io

Full screen playback.

npm.io

Fade out animation.

npm.io

Installation

React-native-ivideo-player uses react-native-video, react-native-orientation, and react-native-linear-gradient. You need to install these dependencies yourself.

installation:

yarn add react-native-ivideo-player

link:

react-native link react-native-video
react-native link react-native-orientation
react-native link react-native-linear-gradient

modify the code in android/build.gradle:

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

Usage

import IVideo from 'react-native-ivideo-player';

<IVideo
    source={{ uri: url }}
    title='title'
    showFullscreenIcon={true}
    width='100%'
    height={240}
    actions={[{
        text: 'select 1',
        onPress: () => { },
    }, {
        text: 'select 2',
        onPress: () => { },
    }]}
/>

Example

Please check example code.

Props

nametypedefaultdescription
widthnumber、string100%video width, @required.
heightnumber、string240video height, @required.
sourceobjectnullvideo data source, @required.
toolbarDurationnumber6000the toolbar displays the duration (ms).
toolbarSliderColorstring#f90the color of the toolbar slider.
titlestring''the title displayed by the toolbar.
showFullscreenIconboolfalsewhether to display the full screen button.
showBackIconbooltruewhether to display the back icon .
autoPlayboolfalsewhether to automatically start playback after the video initialization is completed.
actionsarray{ text, onPress }Functional group.
gradientColorarray'rgba(1, 1, 1, 0.45)', 'rgba(1, 1, 1, 0.24)', 'rgba(1, 1, 1, 0.45)'Gradient color of the occlusion layer.

Map to the properties of react-native-video:

nametypedefaultdescription
progressUpdateIntervalnumber500The call time difference of onProgress (ms).
playInBackgroundboolfalsewhether the video is playing in the background.
mutedboolfalsewhether it is muted.
ratenumber1.0the rate at which the video plays.
repeatboolfalsewhether to repeat the loop playback.
resizeModestring'cover'how the video fills the container.
useTextureViewboolfalsewhether to use useTextureView.
volumenumber1.0The sound size of the video.
seeknumber0The location where the playback starts.

event:

nametypedefaultdescription
onProgressfunctiond => dvideo playback progress event.
onBufferfunctiond => dfires when the video is cached.
onLoadStartfunctione => efires when the video is loadedstart.
onLoadfunctiond => dfires when the video is loaded.
onFullscreenfunctione => efires when the video enters full screen.
onCancelFullscreenfunctione => efires when the video exits full screen.
onPlayfunctione => efires when the video plays.
onPausefunctione => efires when the video is paused.
onEndfunctione => efires when the video ends.
onErrorfunctione => efires when an error occurs in video playback/loading.
onBackfunctione => eTriggered when clicked back.

Method

nametypedescription
playfunctionPlay video
pausefunctionPause video
seekfunctionChange the video playback position
replayfunctionReplay video

Change log

  • v2.0.0: Rewrite code, fix some bugs, add full-screen adaptive video orientation.
  • v1.6: add public method
  • v1.5: add actions props.