react-native-intent-player

[![github home](http://img.shields.io/npm/v/react-native-intent-player.svg?style=flat)](https://www.npmjs.com/package/react-native-intent-player) [![github home](https://img.shields.io/badge/gaetanozappi-react--native--intent--player-blue.svg?style=flat)]

Usage no npm install needed!

<script type="module">
  import reactNativeIntentPlayer from 'https://cdn.skypack.dev/react-native-intent-player';
</script>

README

React Native: Native Intent Player

github home github home github issues

PNG

Android

Add react-native-intent-player to your ./android/settings.gradle file as follows:

...
include ':app'
+ include ':react-native-intent-player'
+ project(':react-native-intent-player').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-intent-player/android/app')

Include it as dependency in ./android/app/build.gradle file:

dependencies {
    ...
    compile "com.facebook.react:react-native:+"  // From node_modules
+   compile project(':react-native-intent-player')
}

Finally, you need to add the package within the ReactInstanceManager of your MainActivity (./android/app/src/main/java/your/bundle/MainActivity.java):

import com.reactlibrary.PlayerPackage;  // <---- import this one
...
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new PlayerPackage()  // <---- add this line
    );
}

After that, you will need to recompile your project with react-native run-android.

Usage

import Player from 'react-native-intent-player';
  • API Way
Player.play(url).then(a => {
  console.log(a);
}).catch(e => console.log(e));

License

This library is provided under the Apache License.