diff --git a/Example/android/app/src/main/java/com/example/MainApplication.java b/Example/android/app/src/main/java/com/example/MainApplication.java index 00ffc8c..b8c5c8d 100644 --- a/Example/android/app/src/main/java/com/example/MainApplication.java +++ b/Example/android/app/src/main/java/com/example/MainApplication.java @@ -23,7 +23,7 @@ protected boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), - new ReactNativeAudioStreamingPackage(MainActivity.class) + new ReactNativeAudioStreamingPackage() ); } }; diff --git a/Example/package.json b/Example/package.json index e66f195..f80a9e8 100644 --- a/Example/package.json +++ b/Example/package.json @@ -7,7 +7,7 @@ }, "dependencies": { "react": "15.2.1", - "react-native": "0.30.0", + "react-native": "0.31.0", "react-native-audio-streaming": "git+https://git@github.com/tlenclos/react-native-audio-streaming.git#master" } } diff --git a/README.md b/README.md index 0bfd74d..8940e99 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ `$ react-native link react-native-audio-streaming` -Go to `node_modules` ➜ `react-native-audio-streaming` => `ios` and add `Pods.xcodeproj` +Go to `node_modules` ➜ `react-native-audio-streaming` => `Pods` and drag/drop `Pods.xcodeproj` to the Libraries folder in your XCode project. In XCode, in the project navigator, select your project. Add `libReactNativeAudioStreaming.a` and `libStreamingKit.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` @@ -30,8 +30,8 @@ In XCode, in the project navigator, select your project. Add `libReactNativeAudi 1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` 2. Go to `node_modules` ➜ `react-native-audio-streaming` => `ios` - run `pod install` to download StreamingKit dependency - - add `ReactNativeAudioStreaming.xcodeproj` - - add `Pods/Pods.xcodeproj` + - add `ReactNativeAudioStreaming.xcodeproj` to the Libraries folder in your XCode project + - add `Pods/Pods.xcodeproj` to the Libraries folder in your XCode project 3. In XCode, in the project navigator, select your project. Add `libReactNativeAudioStreaming.a` and `libStreamingKit.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` 4. Run your project (`Cmd+R`) @@ -39,7 +39,7 @@ In XCode, in the project navigator, select your project. Add `libReactNativeAudi 1. Open up `android/app/src/main/java/[...]/MainActivity.java` - Add `import com.reactlibrary.ReactNativeAudioStreamingPackage;` to the imports at the top of the file - - Add `new ReactNativeAudioStreamingPackage(MainActivity.class)` to the list returned by the `getPackages()` method + - Add `new ReactNativeAudioStreamingPackage()` to the list returned by the `getPackages()` method 2. Append the following lines to `android/settings.gradle`: ``` include ':react-native-audio-streaming' @@ -91,3 +91,9 @@ class PlayerUI extends Component { - Android version based on the work of @EstebanFuentealba https://github.com/EstebanFuentealba/react-native-android-audio-streaming-aac - iOS version based on the work of @jhabdas https://github.com/jhabdas/lumpen-radio + +See also the list of [contributors](https://github.com/tlenclos/react-native-audio-streaming/graphs/contributors) who participated in this project. + +## License + +This project is licensed under the MIT License - see the LICENSE file for details diff --git a/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingModule.java b/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingModule.java index 7f6c2ab..bd15925 100644 --- a/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingModule.java +++ b/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingModule.java @@ -29,9 +29,8 @@ public class ReactNativeAudioStreamingModule extends ReactContextBaseJavaModule private Intent bindIntent; private String streamingURL; - public ReactNativeAudioStreamingModule(ReactApplicationContext reactContext, Class cls) { + public ReactNativeAudioStreamingModule(ReactApplicationContext reactContext) { super(reactContext); - this.clsActivity = cls; this.context = reactContext; } @@ -40,6 +39,9 @@ public ReactApplicationContext getReactApplicationContextModule() { } public Class getClassActivity() { + if (this.clsActivity == null) { + this.clsActivity = getCurrentActivity().getClass(); + } return this.clsActivity; } @@ -77,7 +79,7 @@ public void initialize() { @Override public void onServiceConnected(ComponentName className, IBinder service) { signal = ((Signal.RadioBinder) service).getService(); - signal.setData(this.context, this.clsActivity, this); + signal.setData(this.context, this); WritableMap params = Arguments.createMap(); sendEvent(this.getReactApplicationContextModule(), "streamingOpen", params); } diff --git a/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingPackage.java b/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingPackage.java index a95b055..9536ba0 100644 --- a/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingPackage.java +++ b/android/src/main/java/com/audioStreaming/ReactNativeAudioStreamingPackage.java @@ -15,15 +15,10 @@ public class ReactNativeAudioStreamingPackage implements ReactPackage { private Class clsActivity; - public ReactNativeAudioStreamingPackage(Class activity) { - super(); - this.clsActivity = activity; - } - @Override public List createNativeModules(ReactApplicationContext reactContext) { List modules = new ArrayList<>(); - modules.add(new ReactNativeAudioStreamingModule(reactContext, this.clsActivity)); + modules.add(new ReactNativeAudioStreamingModule(reactContext)); return modules; } diff --git a/android/src/main/java/com/audioStreaming/Signal.java b/android/src/main/java/com/audioStreaming/Signal.java index 920b8ae..7bf4262 100644 --- a/android/src/main/java/com/audioStreaming/Signal.java +++ b/android/src/main/java/com/audioStreaming/Signal.java @@ -61,9 +61,9 @@ public class Signal extends Service implements OnErrorListener, private TelephonyManager phoneManager; private PhoneListener phoneStateListener; - public void setData(Context context, Class clsActivity, ReactNativeAudioStreamingModule module) { + public void setData(Context context, ReactNativeAudioStreamingModule module) { this.context = context; - this.clsActivity = clsActivity; + this.clsActivity = module.getClassActivity(); this.module = module; this.eventsReceiver = new EventsReceiver(this.module); diff --git a/package.json b/package.json index 90c65b9..32b15ee 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "test": "echo \"Not test yet sadly :(\" && exit 0" }, "peerDependencies": { - "react-native": "^0.30.0" + "react-native": "^0.31.0" }, "devDependencies": { - "react-native": "^0.30.0" + "react-native": "^0.31.0" } }