Comments (14)
@chachachacha @rowinf @nycoliver @kilgoremaskreplica @cavilaho
Had the same issue on iOS & Android and was able to fix it.
iOS: My fault I did not choose my target correctly i.e. under built target I had myProjectTests
selected rather than myProject
. Once I fixed this I did not receive any error on iOS.
Android: According to RN docs RNSound
package should be added to getPackages()
method of MainApplication.java
rather than MainActivity.java
. Once I changed this the error went away.
I am using RN version 0.39.2.
Hope this helps.
from react-native-sound.
It's working for me in 0.30. I had the same error, but I found something wrong with my android project configuration. For me, I forgot my import statement in MainApplication.java and my compile project(':RNSound')
was in the wrong place. Hope that helps someone!
from react-native-sound.
If you followed the READMe accurately, you might have added the getPackages method into MainActivity.java
The README is wrong (at the time of typing).
The correct class to add to is MainApplication.java
I think this is the reason that react-native link react-native-sound
works - It mods the correct file.
Please correct the README ASAP. Shitty trap for new users...
from react-native-sound.
I get this issue on ios with rnpm install react-native-sound but manual installation seems to work fine.
from react-native-sound.
@zmxv Also experiencing this bug on RN 0.30 >. Any word on a solution that doesn't involve subverting npm?
from react-native-sound.
@kilgoremaskreplica
Try removing the library and reinstall with
npm install react-native-sound
rnpm link react-native-sound
from react-native-sound.
Working for me on RN 0.32. I solved this issue by manually linking, right this:
android/settings.gradle
include ':RNSound', ':app'
project(':RNSound').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sound/android')
android/app/build.gradle
dependencies {
...
compile project(':RNSound')
...
android/app/src/main/java/com/myApp/MainApplication.java
. . .
import com.zmxv.RNSound.RNSoundPackage;
. . .
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
. . .
new RNSoundPackage()
);
}
from react-native-sound.
react native 0.34 not working
from react-native-sound.
At least for iOS I can confirm that this library is working on react native 0.34.1
from react-native-sound.
i try. IOS is working, but Android not working
from react-native-sound.
I found problem , please update document https://github.com/facebook/react-native/blob/0.35-stable/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java
from react-native-sound.
I am also facing same issue. No solutions described above working for me
from react-native-sound.
I was able to fix the issue undefined is not an object (evaluating 'RNSound.IsAndroid')
on iOS π₯.
What I did was just to reinstall react-native-sound npm install react-native-sound --save
and instead of linking it to xcode/android manually, I used react-native link react-native-sound
to link it automatically, after that the error disappeared.
Just for reference, to play a sound just open xcode, and drag-drop your sound file into the root of the xcode project library:
--AppName
----Libraries
----AppNameTests
----Products
----Resources
----SoundFile.wav
Then tick Copy items if needed, Create folder references and in add to targets select your AppName, then click finish to add it to your project.
Now go to your Project Build Phases and make sure your sound file is listed on Copy Bundle Resources, if it's not in there, add it by drag-drop your sound file.
Now everything should be ready, just don't forget to run your app in xcode to build it.
Here's a sample code I'm using in my React Native app:
import React from 'react';
import { TouchableWithoutFeedback, Text } from 'react-native';
import Sound from 'react-native-sound';
class MyComponent extends Component {
playSound() {
const mySound = new Sound('tap.wav', Sound.MAIN_BUNDLE, (e) => {
if (e) {
console.log('error', e);
} else {
console.log('duration', mySound.getDuration());
mySound.play();
}
});
}
render() {
return (
<TouchableWithoutFeedback onPress={this.playSound.bind(this)}>
<Text>Play Sound!</Text>
</TouchableWithoutFeedback>
);
}
}
And now it's 100% working, I tried it on iOS only, but the original error should be gone on both platforms.
Just don't forget to run the project with xcode, then you can use react-native run-ios
, that's all!
Hope this is helpful! π
from react-native-sound.
Thanks for this. The readme has been updated now. It's now recommended to use react-native link react-native-sound
which means you don't need to manually perform the install steps any more.
from react-native-sound.
Related Issues (20)
- Audio after playing not stopped
- Sound.setCategory('Playback') not working
- Play function stops working after playing multiple videos HOT 1
- Playing the next track in the done callback of the play() function doesn't work HOT 1
- Can not build in Windows HOT 4
- It is not working on Ios version 16.6 HOT 2
- Uncaught Error: Cannot read property 'IsAndroid' of null HOT 2
- React Native 0.71.0 incompatibility HOT 1
- Include Guidelines for Allowing Assets in Audio Files
- Can't play sound from "App Group" paths.
- onEnd callback is not fired on Android if setSpeed() HOT 4
- Γ Build failed with message C:\Users\91626\Downloads\testwindowsapp\node_modules\react-native-sound\windows\RNSoundModule\RNSoundModule\RNSoundPackage.cs(1,7): error CS0246: The type or namespace name 'ReactNative' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\91626\Downloads\testwindowsapp\node_modules\react-native-sound\windows\RNSoundModule\RNSoundModule\RNSoundModule.csproj]. Check your build configuration. HOT 3
- delay between sounds played HOT 3
- Is there a software update plan? HOT 1
- When I send voice note from android to IOS, then failed to load sound in IOS. HOT 1
- Wrong duration value when running methode getDuration()
- η°ε¨iOSη«―θΏθ½η¨εοΌζδΉιζεοΌδΈθ½ζζΎι³ι’ε’οΌ
- bugfixed: Can't play remote mp3 on iOS
- Is it possible to play sound synchronous?
- Error => {"extra": -1330794744, "what": -1003}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-sound.