GithubHelp home page GithubHelp logo

shahen94 / react-native-video-processing Goto Github PK

View Code? Open in Web Editor NEW
1.2K 28.0 321.0 63.54 MB

Native Video editing/trimming/compressing :movie_camera: library for React-Native

Home Page: https://shahen94.github.io/react-native-video-processing/

License: MIT License

Java 3.88% JavaScript 2.05% Objective-C 87.09% Swift 6.45% Ruby 0.07% Shell 0.06% GLSL 0.30% Rich Text Format 0.07% C 0.03%
react react-native video javascript processing xcode ios-video-editor android-video-editor ios android

react-native-video-processing's Introduction

react-native-video-processing

Build Status semantic-release npm version npm package

Getting Started

npm install react-native-video-processing --save
yarn add react-native-video-processing

You can check test by running

$ npm test or $ yarn test

Installation

Note: For RN 0.4x use 1.0 version, for RN 0.3x use 0.16

[Android]

  • Open up android/app/src/main/java/[...]/MainApplication.java

  • Add import com.shahenlibrary.RNVideoProcessingPackage; to the imports at the top of the file

  • Add new new RNVideoProcessingPackage() to the list returned by the getPackages() method

  • Append the following lines to android/settings.gradle:

include ':react-native-video-processing'
project(':react-native-video-processing').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video-processing/android')
  • Insert the following lines inside the dependencies block in android/app/build.gradle:
    compile project(':react-native-video-processing')
  • Add the following lines to AndroidManifest.xml:
   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

[iOS]

  1. In Xcode, right click your Xcode project and create New Group called RNVideoProcessing.

  2. Go to node_modules/react-native-video-processing/ios/RNVideoProcessing and drag the .swift files under the group you just created. Press Create folder references option if not pressed.

  3. Repeat steps 1 & 2 for the subdirectories RNVideoTrimmer, RNTrimmerView, and ICGVideoTrimmer and all the files underneath them. Make sure you keep the folders hierarchy the same.

  4. Go to node_modules/react-native-video-processing/ios/GPUImage/framework and drag GPUImage.xcodeproj to your project's root directory in Xcode.

    Project Structure

  5. Under your project's Build Phases, make sure the .swift files you added appear under Compile Sources.

  6. Under your project's General tab, add the following frameworks to Linked Frameworks and Libraries :

  • CoreMedia
  • CoreVideo
  • OpenGLES
  • AVFoundation
  • QuartzCore
  • MobileCoreServices
  • GPUImage
  1. Add GPUImage.frameworkiOS to Embedded Binaries.

  2. Navigate to your project's bridging header file <ProjectName-Bridging-Header.h> and add #import "RNVideoProcessing.h".

  3. Clean and run your project.

Check the following video for more setup reference.

Setup

Update ffmpeg binaries

  1. Clone mobile-ffmpeg
  2. Setup project, see Prerequisites in README.
  3. Modify build/android-ffmpeg.sh so it generates binaries (more info)
    1. Delete --disable-programs line
    2. Change --disable-static line to --enable-static
    3. Delete --enable-shared line
  4. Compile binaries: ./android.sh --lts --disable-arm-v7a-neon --enable-x264 --enable-gpl --speed. The command might finish with failed. That's okay because we modified the build script. Make sure every build outputs: ffmpeg: ok.
  5. Find ffmpeg binaries in prebuilt/[android-arm|android-arm64|android-x86|android-x86_64]/ffmpeg/bin/ffmpeg
  6. Copy and rename binaries to android/src/main/jniLibs/[armeabi-v7a|arm64-v8a|x86|x86_64]/libffmpeg.so. Make sure you rename the binaries from ffmpeg to libffmpeg.so!

Example Usage

import React, { Component } from 'react';
import { View } from 'react-native';
import { VideoPlayer, Trimmer } from 'react-native-video-processing';

class App extends Component {
    trimVideo() {
        const options = {
            startTime: 0,
            endTime: 15,
            quality: VideoPlayer.Constants.quality.QUALITY_1280x720, // iOS only
            saveToCameraRoll: true, // default is false // iOS only
            saveWithCurrentDate: true, // default is false // iOS only
        };
        this.videoPlayerRef.trim(options)
            .then((newSource) => console.log(newSource))
            .catch(console.warn);
    }

    compressVideo() {
        const options = {
            width: 720,
            height: 1280,
            bitrateMultiplier: 3,
            saveToCameraRoll: true, // default is false, iOS only
            saveWithCurrentDate: true, // default is false, iOS only
            minimumBitrate: 300000,
            removeAudio: true, // default is false
        };
        this.videoPlayerRef.compress(options)
            .then((newSource) => console.log(newSource))
            .catch(console.warn);
    }

    getPreviewImageForSecond(second) {
        const maximumSize = { width: 640, height: 1024 }; // default is { width: 1080, height: 1080 } iOS only
        this.videoPlayerRef.getPreviewForSecond(second, maximumSize) // maximumSize is iOS only
        .then((base64String) => console.log('This is BASE64 of image', base64String))
        .catch(console.warn);
    }

    getVideoInfo() {
        this.videoPlayerRef.getVideoInfo()
        .then((info) => console.log(info))
        .catch(console.warn);
    }

    render() {
        return (
            <View style={{ flex: 1 }}>
                <VideoPlayer
                    ref={ref => this.videoPlayerRef = ref}
                    startTime={30}  // seconds
                    endTime={120}   // seconds
                    play={true}     // default false
                    replay={true}   // should player play video again if it's ended
                    rotate={true}   // use this prop to rotate video if it captured in landscape mode iOS only
                    source={'file:///sdcard/DCIM/....'}
                    playerWidth={300} // iOS only
                    playerHeight={500} // iOS only
                    style={{ backgroundColor: 'black' }}
                    resizeMode={VideoPlayer.Constants.resizeMode.CONTAIN}
                    onChange={({ nativeEvent }) => console.log({ nativeEvent })} // get Current time on every second
                />
                <Trimmer
                    source={'file:///sdcard/DCIM/....'}
                    height={100}
                    width={300}
                    onTrackerMove={(e) => console.log(e.currentTime)} // iOS only
                    currentTime={this.video.currentTime} // use this prop to set tracker position iOS only
                    themeColor={'white'} // iOS only
                    thumbWidth={30} // iOS only
                    trackerColor={'green'} // iOS only
                    onChange={(e) => console.log(e.startTime, e.endTime)}
                />
            </View>
        );
    }
}

Or you can use ProcessingManager without mounting VideoPlayer component:

import React, { Component } from 'react';
import { View } from 'react-native';
import { ProcessingManager } from 'react-native-video-processing';
export class App extends Component {
  componentWillMount() {
    const { source } = this.props;
    ProcessingManager.getVideoInfo(source)
      .then(({ duration, size, frameRate, bitrate }) => console.log(duration, size, frameRate, bitrate));
  
    // on iOS it's possible to trim remote files by using remote file as source
    ProcessingManager.trim(source, options) // like VideoPlayer trim options
          .then((data) => console.log(data));

    ProcessingManager.compress(source, options) // like VideoPlayer compress options
              .then((data) => console.log(data));

    ProcessingManager.reverse(source) // reverses the source video 
              .then((data) => console.log(data)); // returns the new file source

    ProcessingManager.boomerang(source) // creates a "boomerang" of the surce video (plays forward then plays backwards)
              .then((data) => console.log(data)); // returns the new file source

    const maximumSize = { width: 100, height: 200 };
    ProcessingManager.getPreviewForSecond(source, forSecond, maximumSize)
      .then((data) => console.log(data))
  }
  render() {
    return <View />;
  }
}

If this project was helpful to you, please Buy Me A Coffee

Contributing

  1. Please follow the eslint style guide.
  2. Please commit with $ npm run commit

Roadmap

  1. Use FFMpeg instead of MP4Parser
  2. Add ability to add GLSL filters
  3. Android should be able to compress video
  4. More processing options
  5. Create native trimmer component for Android
  6. Provide Standalone API
  7. Describe API methods with parameters in README

react-native-video-processing's People

Contributors

adamawang avatar baderserhan avatar benbrostoff avatar charlyberthet avatar code-diggers-369 avatar denisbevilacqua avatar dependabot[bot] avatar ebellumat avatar edferreira avatar flybayer avatar gevgasparyan avatar gvillenave avatar hhravn avatar jaspermeijaard avatar jberendes avatar joshm1994 avatar kashifsulaiman avatar kesha-antonov avatar kobidl avatar nazwa avatar santiagovazquez avatar shahen94 avatar slavasemeniuk avatar soledaddiez avatar superandrew213 avatar teal-labs-developer avatar tinaroh avatar toggm avatar wehriam avatar zachrnolan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-video-processing's Issues

What does this do? [REQUEST - Update Description by adding Features / Snapshots]

I noticed the video didn't show it in action and I didn't see a description describing this project, rather, it just shows how to set it up.

by looking at your code from my understanding it does the following:

  • records videos
  • allows you to trim the video before you save
  • save to camera roll

is that correct?

Any snapshots would be great or a description of its features would be great.

Problem with source, no view loaded.

I'm trying the usage example from readme, i use

<VideoPlayer
....
source={{ uri: this.props.uri }}
....
/>

and also for Trimmer

<Trimmer
....
source={{ uri: this.props.uri }}
....
/>

but, i got warning 'Failed prop type: Invalid prop source supplied to VideoPlayer' and no view loaded, also same for Trimmer . i got this in ios and android. did i miss something ?

then i'm trying using source={require('./video.mp4')} no error and no view loaded.

if you don't mind, would you add an example ?

thx

Library not loaded: @rpath/GPUImage.framework/GPUImage

dyld: Library not loaded: @rpath/GPUImage.framework/GPUImage
  Referenced from: /var/containers/Bundle/Application/6C9C98B2-35FE-4847-B7C8-D6D1B54B4E83/<MyAppName>.app/<MyAppName>
  Reason: image not found

Hey there,

Unable to load on real iOS device (works in Simulator). Both Clean and Build succeeds in XCode, but getting the above error when the app tries to open on my iPhone.
Did all setup steps for iOS, tried restarting Xcode and computer, no help.
GPUImage.xcodeproj is definitely on the "top" level, along with RNVideoProcessing.

Here is the contents of my bridging header file:

//
//  <MyAppName>-Bridging-Header.h
//  <MyAppName>
//
//  Created by Petr Gazarov on 6/4/17.
//  Copyright © 2017 Facebook. All rights reserved.
//

#ifndef <MyAppName>_Bridging_Header_h
#define <MyAppName>_Bridging_Header_h

#import "RNVideoProcessing.h"

#endif /* <MyAppName>_Bridging_Header_h */

<MyAppName> replaced the actual app name.
I also attempted this fix, but no avail.
Tried version 1.8.0 of this library, as well as latest and directly from master.

Is it intended that the app is looking for @rpath/GPUImage.framework/GPUImage whereas the actual file name is GPUImage.xcodeproj?


Environment
MacOS Sierra 10.12.5
XCode 8.3.2
iOS 10.2.1
react-native 0.44.2

Save Video

We should be able to trim and save video

Trim View display only first frame

I have notice that the trimming component replicates the first frame of the video over and over again. Is it right, or is it something that I'm doing wrong?

For example, if my video starts with a black screen, the trimming view shows as completely black.

ProcessingManager Android Error

Hi,

I am trying to use the ProcessingManager exactly as described in the example, but I am getting the following error:

undefined is not an object (evaluating '_reactNativeVideoProcessing2.default.getVideoInfo')

Not sure what to make of that. I am on Android, RN Version 0.45. react-native run-android builds the app without problems, but as soon as I try to call any function of the ProcessingManager, I get the the above error.

Android: Losing the trimmer thumb handlers

I have the trimmer set to the width of the screen. Thumb handlers disappear seemingly off the side of the screen. Position tracking on the the drag or release must be getting an invalid location.
This should be contained as to not go beyond 0 or the end of the video.

Failed to import GPUImage.h

Hey There,

I have followed all the steps described on README.md but I can not figure out why this error is happening

/Users/barbaragomes/Projects/intellectmobile/ios/intellectApp-Bridging-Header.h:9:9: note: in file included from /Users/barbaragomes/Projects/intellectmobile/ios/intellectApp-Bridging-Header.h:9:
#import "RNVideoProcessing.h"
        ^
/Users/barbaragomes/Projects/intellectmobile/node_modules/react-native-video-processing/ios/RNVideoProcessing/RNVideoProcessing.h:11:9: error: 'GPUImage.h' file not found
#import "GPUImage.h"
        ^
<unknown>:0: error: failed to import bridging header '/Users/barbaragomes/Projects/intellectmobile/ios/intellectApp-Bridging-Header.h'

Any Suggestions?

Also, is it compatible with Swift 3? Or do I have to make the changes to RNProcessingVideo files manually in order to be compatible with Swift3?

VideoPlayer

VideoPlayer is not working, or how to set currentTime, or pause ?

Video Compression

Please can I do video compression and resizing on android now?

If So the doc should reflect it. The IOS only part

Trimmer glitching

Trimmer glitches when trying to grab the start, end, or current position of trimmer.
Is anyone else having this issue? I'll see if I can get a recording.

Possible to concatenate videos?

Hi there,

is it or will it be possible to take multiple videos as input trim them and then concatenate them into one video file which can then be saved to camroll or something?

Just a question, so feel free to label it as such or close it right away if it disturbs you, but maybe it can also be seen as a enhancement idea.

Thanks in any case

Video Layer displayed twice

Hey there,

I upgrade to the latest version but I notice that a bug (not sure if it is a bug) start happening on version 1.7.0 and up. I can see the video layer twice in the screen:

video

Here is my react-native code:

<VideoPlayer
    ref={ref => this.player = ref}
    currentTime={this.state.currentVideoTime}
    play={this.state.playing}     // default false
    startTime={this.state.start_trim}  // seconds
    endTime={this.state.end_trim}   // seconds
    replay={false}   // should player play video again if it's ended
    rotate={true}   // use this prop to rotate video if it captured in landscape mode
    source={this.props.original_asset}
    playerWidth={deviceResolution.width}
    playerHeight={0.7 * deviceResolution.height}
    style={{ backgroundColor: 'black' }}
    onChange={({ nativeEvent }) => this.playingEvent({ nativeEvent })}
    resizeMode={VideoPlayer.Constants.resizeMode.CONTAIN}
/>

Any ideas? That does not happen up to version 1.6.0

Thanks

ffmpeg not resolving correctly

Error:Failed to resolve: com.github.kesha-antonov:ffmpeg-android-java:e69ea470d69d271fafbd03d0a4b0ea67d6731ccc

@kesha-antonov, what actions need to be taken to get this dependency working?

This is a breaking bug for me.

Android only: no progress bar or indicator in trimmer

It seems like this is missing on Android. Could be something I'm failing to do configuration-wise or it was never implemented. Or maybe this should just be considered a feature request. Thoughts? My time to dig into it has been short as of late but should some open up I'll let you know if I start working on it.

Failing to trim video ("operation is not supported for this media")

I'm trying to trim a video using VideoPlayer.trim(), but it keeps failing with this error:

Failed: Optional(Error Domain=AVFoundationErrorDomain Code=-11838 "Operation Stopped" 
UserInfo={NSUnderlyingError=0x170656cb0 {Error Domain=NSOSStatusErrorDomain Code=-12109 "(null)"}, 
NSLocalizedFailureReason=The operation is not supported for this media., 
NSLocalizedDescription=Operation Stopped})

I've tried different configs and videos with no success, including linking one video to the player and another to trim(). However, <VideoPlayer> can play the video just fine.

Maybe this isn't an issue with this library, but I'm new to iOS video processing (and RN in general) and figured I'd start here.

Are there special permissions or settings I need in my app for this?

Thanks for any help!!

The main sample video I'm trying to trim:

http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_5mb.mp4

My Code:

export default class App extends Component {
  trimVideo = () => {
    const options = {
      startTime: 0,
      endTime: 5,
    };
    this.videoPlayerRef.trim(require('./videoFile.mp4'), options)
      .then((newSource) => console.log(newSource))
      .catch(console.warn);
  }

...

  render() {
    return (
      <View style={{ flex: 1 }}>
        <View style={{ flex: 3 }}>
          <VideoPlayer
            ref={ref => this.videoPlayerRef = ref}
            play={true}
            replay={true}
            source={require('./videoFile.mp4')}
            playerWidth={300}
            playerHeight={500}
            style={{ backgroundColor: 'black' }}
            onChange={({ nativeEvent }) => console.log('change:', { nativeEvent })}
          />
        </View>
        <View style={{ flex: 1 }}>
          <TouchableOpacity
            onPress={this.trimVideo}
            style={{backgroundColor: 'yellow'}}
          >
            <Text>Trim & Save</Text>
          </TouchableOpacity>
        </View>
      </View>
    )
  }
}

Increase tap surface for start and end handles

The trimmer works if can tap and get ahold of the shaded area to the left of the start or to the right of the end. When it starts it's likely at 0. Obviously grabbing something with 0 width is hard. It takes about 3 to 5 tries to get ahold of the left trimmer and even more for the right one. Is there a way to increase the hitslop of these? Would anyone else find it worthwhile to add a handleHitslop property?

Can't make it work

After adding library to my project it displays error

addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's `render` method, or you have multiple copies of React loaded

Android compression timeline

Is anyone working on the compression feature for Android ? I see the checkbox but was wondering if it means someone is working on it and if we can expect it anytime soon ?

Swift is not supported for static libraries

Hi,

I just started a project with RN and I'm trying to use this library (I'm not familiar with iOS development).

I followed the steps on the readme. I did not have the bridging header file so I followed: #14

XCode won't compile my project, I'm getting "Swift is not supported for static libraries" for RNVideoProcessing:
screen shot 2017-03-18 at 1 26 02 pm

Thanks in advance for any help you can give me! 😃

android time line

i'm good at android .the ios code is very strong. and i want to know how the android platfrom support

iOS: Swift is not supported for static libraries.

screen shot 2017-06-29 at 10 53 14 am

I admit this is a duplicate of #48 but that ticket is closed and I continue to have the issue.

Using RN 0.45.1

Steps to reproduce:

  1. npm install react-native-video-processing --save
  2. react-native link
  3. Build fails in Xcode with above error
  4. Followed the following set-up guide: https://www.youtube.com/watch?v=HRjgeT6NQJM
  5. Clean & Build both fail in Xcode with the above error (still)

Here is my setup:

screen shot 2017-06-29 at 10 52 39 am

Please, someone help! :) I would LOVE to be able to use this library

[Android] Low quality of getFrameAt

Hello, @shahen94 !

I'm working on some features for this lib right now.

When do I try to get preview of video as image I see it in a low quality. Do you have thoughts how to improve this?

I searched for MediaMetadataRetriever. And appears that it has low quality when capturing frame if I'm not mistaken.

They advice to use MediaCoder: http://stackoverflow.com/questions/31789609/android-bitmap-compress-poor-quality-with-png-format

Also I found that is possible to set config for generated bitmap. But it's commented out in FFMpeg library: https://github.com/wseemann/FFmpegMediaMetadataRetriever/blob/6c3be9da13252a8333958feda8a6df29e0502d28/gradle/fmmr-library/library/src/main/java/wseemann/media/FFmpegMediaMetadataRetriever.java#L562-L568

Have you tried to generate image previews in good quality?

Default some values rather than require constants or other values

This is certainly an enhancement request and I would be willing to help with the updates but would require a brief discussion.

To keep the code little more lean consider the best/common use case and set default values.
example:
Dont't make the dev write::

<VideoPlayer
ref={ref => this.videoPlayerRef = ref}
startTime={30}  // seconds
endTime={120}   // seconds
play={true}     // default false
replay={true}   // should player play video again if it's ended
rotate={true}   // use this prop to rotate video if it captured in landscape mode iOS only
source={'file:///sdcard/DCIM/....'}
playerWidth={300} // iOS only
playerHeight={500} // iOS only
style={{ backgroundColor: 'black' }}
resizeMode={VideoPlayer.Constants.resizeMode.CONTAIN}
onChange={({ nativeEvent }) => console.log({ nativeEvent })} // get Current time on every second
/>

when defaults would allow them to write::

<VideoPlayer
ref={ref => this.videoPlayerRef = ref}
source={'file:///sdcard/DCIM/....'}
onChange={({ nativeEvent }) => console.log({ nativeEvent })} // get Current time on every second
/>

Defaults: startTime=0, endTime=null, play=true, replay=false, rotate=true, playerWidth=window.width, payerHeight=window.height, style=null, resizeMode=VideoPlayer.Constants.resizeMode.COVER
(these defaults represent my best guess)

Everything here is just a recommendation and I hope you will consider it.

getting an error when testing with sample code

Hi, I tried creating a sample project to test out the module but I'm getting this error when the application loads.
I followed all the steps as given in the Readme and I'm just using the example code
Here is a screen shot.
I have tried a number of things but I'm always getting this error. Any ideas?

screen shot 2017-05-01 at 3 58 00 pm

“Swift Language Version” (SWIFT_VERSION) build error

“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

Hello , and thanks for the work you've put in this library, I look forward to using it.
Don't really know if this is more of an xcode problem or about plans of supporting the new Swift version.I'm trying to install on xcode 8.3, react-native 0.43.3, and I get the above error. If I go to my Build Settings / Swift Language Version, there's a Swift 2.3 (unsupported) option and a Swift 3 one.
I get compiler errors on Swift 3. I tried converting the code with Edit/Convert/To Current Swift Syntax... and I get rid of some of the errors, but there's still about 50 of them left.
I tried my google fu for fixing it, but I'm no swift/objective-c developer
Cheers!
Edit

Update:

Downgraded version of xcode to 8.21 to use legacy version of swift and I still get some errors:
errors.

[Android] Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference

RN 0.45.1

onCaptureMedia(mediaData) {
    console.log('mediaData: ', mediaData)
    const maximumSize = { width: 1080, height: 1080 };
    ProcessingManager.getPreviewForSecond(mediaData.path, 4, maximumSize, 'JPEG')
      .then(thumbnail => {
        console.log('previewForSecond: ', thumbnail)
        this.props.dispatch(PostReactionState.videoRecorded(mediaData.path, thumbnail))
      })
  },

I get a console.log for mediaData with a valid path to the video file. I never see the console.log for previewForSecond.

This works fine on iOS.

image

Getting android build error

Sometimes I'm getting this error

:react-native-video-processing:processDebugAndroidTestManifest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-video-processing:processDebugAndroidTestManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library [com.github.kesha-antonov:ffmpeg-android-java:e69ea470d69d271fafbd03d0a4b0ea67d6731ccc] /Users/andrew/src/jh-mobile/node_modules/react-native-video-processing/android/build/intermediates/exploded-aar/com.github.kesha-antonov/ffmpeg-android-java/e69ea470d69d271fafbd03d0a4b0ea67d6731ccc/AndroidManifest.xml
     Suggestion: use tools:overrideLibrary="com.github.hiteshsondhi88.libffmpeg" to force usage

Where do we need to add tools:overrideLibrary="com.github.hiteshsondhi88.libffmpeg" to avoid that? @kesha-antonov
My minSdkVersion is 17 in both AndroidManifest.xml and app/build.gradle

suggestions (PRs will follow if accepted)

  1. remove constructor calls completely
  2. use default for exporting components
  3. consistency
  4. react/sort-comp
  5. advanced reconstructing
  6. perf: VideoPlayer

NOTE:

disregard indentation in my examples, PRs will b sent in current linting rules of course

lemme know what u think of these suggestions! :)

remove constructor calls completely

so this:

export class Trimmer extends Component {
    // ...
  constructor(...args) {
    super(...args);
    this.state = {};
    this._onChange = this._onChange.bind(this);
  }

  _onChange(event) {
    if (!this.props.onChange) {
      return;
    }
    this.props.onChange(event.nativeEvent);
  }

becomes:

export class Trimmer extends Component {
//...
  state = {}

  _onChange = (event) => {
      if (!this.props.onChange) {
          return;
      }
      this.props.onChange(event.nativeEvent);
  }

use default for exporting components

this:

// Trimmer/index.js
export { Trimmer } from './Trimmer'

// lib/index.js
export { Trimmer } from './Trimmer';

becomes

// Trimmer/index.js
import Trimmer from './Trimmer'
export default Trimmer

// lib/index.js
export Trimmer from './Trimmer';

consistency

whether or not point 3 gets implemented:
this:

export {
  VideoPlayer
} from './VideoPlayer';
export { Trimmer } from './Trimmer';

becomes

export { VideoPlayer } from './VideoPlayer';
export { Trimmer } from './Trimmer';

add react/sort-comp

looks like this repo has static methods first, and render is last, in the case your configuration would b something like:

    "react/sort-comp": [2,
      {
        "order": [
          "static-methods",
          "lifecycle", // not sure u need this?
          "everything-else",
          "render",
        ]
      }
    ],

advanced reconstructing

this:

// lib/VideoPlayer/VideoPlayer.js
  render() {
    const {
      // ...
      source,
    } = this.props;

    const actualSource = getActualSource(source);
    return (
      <RNVideoPlayer
        source={actualSource}
        // ...
      />
    );
  }

becomes

  render() {
    const {
      // ...
      source: getActualSource(source),
    } = this.props;

    return (
      <RNVideoPlayer
        source={source}
        // ...
      />
    );
  }

perf: VideoPlayer

running getActualSource(source) will probably lead to unnecessary processing done by:
import resolveAsset from 'react-native/Libraries/Image/resolveAssetSource';

I don't know how expensive this is, tho it might b better to either use shouldComponentUpdate or something like:

state = {
  source: getActualSource(this.props.source)
}
componentWillReceiveProps(nextProps) {
  if (nextProps.source === this.props.source) {
    return
  }
  this.setState({ source: getActualSource(source) })

  // ...

render() {
      <RNVideoPlayer
        source={this.state.source}
        // ...
      />
}
}

VideoPlayer throws `EXC_BAD_INSTRUCTION`

screen shot 2017-06-30 at 3 42 20 pm

I'm having a difficult time using the VideoPlayer component (on iOS). Here is my component:

<VideoPlayer
    ref={ref => this.videoPlayerRef = ref}
    source={this.props.uri}
    style={{ backgroundColor: 'black' }}
    resizeMode={VideoPlayer.Constants.resizeMode.CONTAIN}
/>

Do you know why I get this error? Could you document the usage a little better?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.