Comments (45)
Just replace Sound.MAIN_BUNDLE by an empty string.
Worked for me
from react-native-sound.
add the file to Xcode Resources.
from react-native-sound.
@amed Had this problem.
Solved it by adding Sound.MAIN_BUNDLE to the Sound constructor and moving the .mp3 files to the resources folder of the project in XCode.
(Note: Keeps working on Android without problems)
Constructor
var Beep = new Sound('beep_high.mp3', Sound.MAIN_BUNDLE);
from react-native-sound.
hello
I have the same problem with IOS when i try this
playTrack(parent){
const track = new Sound('https://www.soundjay.com/button/button-1.mp3',null, (e) => {
if (e) {
console.log(e)
} else {
track.play()
}
})
}
work good but when i try with the link firebase storage not working
playTrack(parent){
const track = new Sound('https://firebasestorage.googleapis.com/v0/b/prj1-aa7b3.appspot.com/o/Chat_audio%2Fbutton-1%20(1).mp3?alt=media&token=39d18256-25c0-4948-b0d8-12c3f626a26a',null, (e) => {
if (e) {
console.log(e)
} else {
track.play()
}
})
}
The error I receive is:
[info][tid:com.facebook.react.JavaScript] { code: 'ENSOSSTATUSERRORDOMAIN-10875',
nativeStackIOS:
[ '0 MyApp 0x00000001001ac318 RCTJSErrorFromCodeMessageAndNSError + 152',
from react-native-sound.
Any workaround to play sound over HTTP protocol? didn't see any successful example.
I don't even think this project support playing sound over HTTP at all. never seem a workable example :(
from react-native-sound.
If anyone else arrives here: we got this working after putting the file in the Xcode Resources directory, then redeploying with react-native run-ios
. Not sure if restarting the packager was necessary.
from react-native-sound.
Handling both android and ios:
import { Platform } from 'react-native';
import Sound from 'react-native-sound';
const mainBundle = Platform.OS === 'ios'
? encodeURIComponent(Sound.MAIN_BUNDLE)
: Sound.MAIN_BUNDLE;
export const notifAlert = new Sound('notif_alert.mp3', mainBundle, error => {
if (error) console.error(error);
});
from react-native-sound.
hello I have the same problem with IOS when i try this playTrack(parent){ const track = new Sound('https://www.soundjay.com/button/button-1.mp3',null, (e) => { if (e) { console.log(e) } else { track.play() } }) } work good but when i try with the link firebase storage not working playTrack(parent){ const track = new Sound('https://firebasestorage.googleapis.com/v0/b/prj1-aa7b3.appspot.com/o/Chat_audio%2Fbutton-1%20(1).mp3?alt=media&token=39d18256-25c0-4948-b0d8-12c3f626a26a',null, (e) => { if (e) { console.log(e) } else { track.play() } }) } The error I receive is:
[info][tid:com.facebook.react.JavaScript] { code: 'ENSOSSTATUSERRORDOMAIN-10875', nativeStackIOS: [ '0 MyApp 0x00000001001ac318 RCTJSErrorFromCodeMessageAndNSError + 152',
Did you make it work ? I have the same issue.
from react-native-sound.
Thanks @FRodrigues21 for response, in my example the file is uri. BUT tried also to download it with react-native-fetch-blob and then play it, same issue.
from react-native-sound.
Why should I
add the file to Xcode Resources
? I'm trying to read a file I just recorded, that just got stored in the phone's internal storage...
from react-native-sound.
Got the same error as above, but closing xcode and opening it again made it work. Thank you lukecwilliams for leading me in the right direction
from react-native-sound.
For iOS what worked for me is the following:
- Checked that my resource file was being played in xCode
- Open xCode
- Select the file
- Click play in the xCode player
- Once it was playing sound (had issues with some files, possibly encoding),
- Add the file as resource (Make sure is in Build Phases)
- Compile the project in xCode and run it from there
- Note: Every time you change the resources or expect new resources you need to compile your Native application either by doing it from xCode or
npm run ios
This is my code:
const sound = new Sound(
"myFile.mp3",
Sound.MAIN_BUNDLE,
error => {
if (error) {
console.log("failed to load the sound", error);
return;
}
sound.play(() => sound.release());
}
);
// The play dispatcher
sound.play();
from react-native-sound.
take a look at #334
from react-native-sound.
I was convinced this was my issue and that I'd have to watch this one hoping it would get re-opened, but the solution by @cooperka here : #89 worked for me.
from react-native-sound.
@pierroo i have the same problem. For me it started after i upgraded react native to 0.66
from react-native-sound.
@pierroo I had created a sound manager package, you can try it, I also have an option for download and play as a local file. I'm using it and don't get any issues, hope it's helpful! https://github.com/minhchienwikipedia/react-native-sound-manager
from react-native-sound.
Hi! I have the same problem, I've followed the readme file and added the mp3 as a resource in Xcode project. Also I've added the library according to readme-file. Below is my code, the path on the file in X-code project is set to "Relative to Project" and is "../audio/soundfile.mp3"
var music = new Sound('../audio/soundfile.mp3', Sound.MAIN_BUNDLE, (error) => {
if (error) {
alert('error:' + error);
console.log('failed to load the sound', error);
}
else { // loaded successfully
console.log('duration in seconds: ' + music.getDuration() +
'number of channels: ' + music.getNumberOfChannels());
}
});
The error I get is,
<Notice>: 'failed to load the sound', { code: 'ENSOSSTATUSERRORDOMAIN2003334207', message: 'The operation couldn’t be completed. (OSStatus error 2003334207.)', nativeStackIOS: [ '0 ElevatorMusic 0x000000010be76896 RCTJSErrorFromCodeMessageAndNSError + 134', '1 ElevatorMusic 0x000000010be767c3 RCTJSErrorFromNSError + 275', '2 ElevatorMusic 0x000000010bdd151e -[RNSound prepare:withKey:withCallback:] + 958', '3 CoreFoundation 0x000000010dad705c __invoking___ + 140', '4 CoreFoundation 0x000000010dad6ee1 -[NSInvocation invoke] + 289', '5 CoreFoundation 0x000000010daeeed6 -[NSInvocation invokeWithTarget:] + 54', '6 ElevatorMusic 0x000000010bdfb1af -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1887', '7 ElevatorMusic 0x000000010be53d88 -[RCTBatchedBridge _handleRequestNumber:moduleID:methodID:params:] + 680', '8 ElevatorMusic 0x000000010be52eca __33-[RCTBatchedBridge handleBuffer:]_block_invoke.494 + 1274', '9 libdispatch.dylib 0x0000000111a2c810 _dispatch_call_block_and_release + 12', '10 libdispatch.dylib 0x0000000111a4e12e _dispatch_client_callout + 8', '11 libdispatch.dylib 0x0000000111a33523 _dispatch_queue_serial_drain + 1018', '12 libdispatch.dylib 0x0000000111a33cf3 _dispatch_queue_invoke + 1118', '13 libdispatch.dylib 0x0000000111a3409b _dispatch_queue_override_invoke + 376', '14 libdispatch.dylib 0x0000000111a35a0e _dispatch_root_queue_drain + 506', '15 libdispatch.dylib 0x0000000111a357b4 _dispatch_worker_thread3 + 113', '16 libsystem_pthread.dylib 0x0000000111df44de _pthread_wqthread + 1129', '17 libsystem_pthread.dylib 0x0000000111df2341 start_wqthread + 13' ], domain: 'NSOSStatusErrorDomain' }
from react-native-sound.
Hmm... for some reason it just started working. Not sure what I did though, but I stopped getting the error and suddenly I heard the sound.
from react-native-sound.
It sounds like the issue has been resolved, so I'm closing this.
from react-native-sound.
same error
I add file in the Xcode Resources and redeploy with react-native run-ios
but to no avail :(
from react-native-sound.
@lossen sometimes you have to close XCode and open it again before it starts working after adding the file to the XCode resources.
A clean build will also help ;-)
from react-native-sound.
Does this relate to relinking?
from react-native-sound.
it seems that this issue is back again:
"react": "16.0.0",
"react-native": "0.50.0",
componentDidMount () {
const url = 'http://www.soundhelix.com/examples/mp3/SoundHelix-Song-6.mp3'
this.player = new Sound(url, Sound.MAIN_BUNDLE, (error) => {
if (error) {
console.log('failed to load the sound', error)
return
}
console.log('duration in seconds: ' + this.player.getDuration() + 'number of channels: ' + this.player.getNumberOfChannels())
})
}
Native stack nativeStackIO
:
0: "0 the_app 0x000000010b7f7276 RCTJSErrorFromCodeMessageAndNSError + 134"
1: "1 the_app 0x000000010b7f71a3 RCTJSErrorFromNSError + 275"
2: "2 the_app 0x000000010b98eef5 -[RNSound prepare:withKey:withOptions:withCallback:] + 1493"
3: "3 CoreFoundation 0x000000010e0f549c __invoking___ + 140"
4: "4 CoreFoundation 0x000000010e0f5370 -[NSInvocation invoke] + 320"
5: "5 CoreFoundation 0x000000010e10dd56 -[NSInvocation invokeWithTarget:] + 54"
6: "6 the_app 0x000000010b7a59bc -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2796"
7: "7 the_app 0x000000010b83c332 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 786"
8: "8 the_app 0x000000010b83be5f _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127"
9: "9 the_app 0x000000010b83bdd9 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25"
10: "10 libdispatch.dylib 0x00000001127eb273 _dispatch_call_block_and_release + 12"
11: "11 libdispatch.dylib 0x00000001127ec2b5 _dispatch_client_callout + 8"
12: "12 libdispatch.dylib 0x00000001127f3e3f _dispatch_queue_serial_drain + 654"
13: "13 libdispatch.dylib 0x00000001127f4690 _dispatch_queue_invoke + 329"
14: "14 libdispatch.dylib 0x00000001127f0d94 _dispatch_queue_override_invoke + 477"
15: "15 libdispatch.dylib 0x00000001127f6a72 _dispatch_root_queue_drain + 568"
16: "16 libdispatch.dylib 0x00000001127f67dc _dispatch_worker_thread3 + 119"
17: "17 libsystem_pthread.dylib 0x0000000112ca15a2 _pthread_wqthread + 1299"
18: "18 libsystem_pthread.dylib 0x0000000112ca107d start_wqthread + 13"
from react-native-sound.
@FRodrigues21 solution worked for me in iOS and Android
from react-native-sound.
have the same problem in IOS simulator,
but found a workaround:
change RNSound.m line194-197 to
fileNameUrl = [NSURL URLWithString: fileName];
NSData* data = [NSData dataWithContentsOfURL:fileNameUrl] ;
player = [[AVAudioPlayer alloc]
initWithData:data
error:&error];
it seems that AVAudioPlayer.initWithContentsOfURL could not load directly with filename , we have to first read it into memory then it's happy to load.
from react-native-sound.
I'm also unable to get this working either on simulator or on an actual device – I've downloaded an mp3 file and saved it to my app's documents directory but get the same error when I try and create a Sound
. I haven't been able to try the solution posted by @fatfatson but that would require some library changes anyway. Has anyone managed to solve this?
from react-native-sound.
@fatfatson I tried your fix but it's not working either. I'm recording some audios and then try to reproduce them but sometimes (1 out of 3) the file is not loaded.
Is there any way to check if the file is in the filesystem?
Thanks!
from react-native-sound.
Can you please @benvium reopen this issue!?
it seems like it is still not solved.
from react-native-sound.
Just replace Sound.MAIN_BUNDLE by an empty string.
Worked for me
thanks, working for me
from react-native-sound.
Just replace Sound.MAIN_BUNDLE by an empty string.
Worked for me
Worked for me too!!!
from react-native-sound.
hello
I have the same problem with IOS when i try this
playTrack(parent){
const track = new Sound('https://www.soundjay.com/button/button-1.mp3',null, (e) => {
if (e) {
console.log(e)
} else {
track.play()
}
})
}
work good but when i try with the link firebase storage not working
playTrack(parent){
const track = new Sound('https://firebasestorage.googleapis.com/v0/b/prj1-aa7b3.appspot.com/o/Chat_audio%2Fbutton-1%20(1).mp3?alt=media&token=39d18256-25c0-4948-b0d8-12c3f626a26a',null, (e) => {
if (e) {
console.log(e)
} else {
track.play()
}
})
}
The error I receive is:[info][tid:com.facebook.react.JavaScript] { code: 'ENSOSSTATUSERRORDOMAIN-10875',
nativeStackIOS:
[ '0 MyApp 0x00000001001ac318 RCTJSErrorFromCodeMessageAndNSError + 152',
replace the 'MAIN_BUNDLE' with null works fine for me. Not sure about firebase though
from react-native-sound.
const mainBundle = Platform.OS === 'ios' ? encodeURIComponent(Sound.MAIN_BUNDLE) : Sound.MAIN_BUNDLE;
Thank you. Worked for me
from react-native-sound.
Handling both android and ios:
import { Platform } from 'react-native'; import Sound from 'react-native-sound'; const mainBundle = Platform.OS === 'ios' ? encodeURIComponent(Sound.MAIN_BUNDLE) : Sound.MAIN_BUNDLE; export const notifAlert = new Sound('notif_alert.mp3', mainBundle, error => { if (error) console.error(error); });
It works for me. Thank you @aprilmintacpineda
from react-native-sound.
hello I have the same problem with IOS when i try this playTrack(parent){ const track = new Sound('https://www.soundjay.com/button/button-1.mp3',null, (e) => { if (e) { console.log(e) } else { track.play() } }) } work good but when i try with the link firebase storage not working playTrack(parent){ const track = new Sound('https://firebasestorage.googleapis.com/v0/b/prj1-aa7b3.appspot.com/o/Chat_audio%2Fbutton-1%20(1).mp3?alt=media&token=39d18256-25c0-4948-b0d8-12c3f626a26a',null, (e) => { if (e) { console.log(e) } else { track.play() } }) } The error I receive is:
[info][tid:com.facebook.react.JavaScript] { code: 'ENSOSSTATUSERRORDOMAIN-10875', nativeStackIOS: [ '0 MyApp 0x00000001001ac318 RCTJSErrorFromCodeMessageAndNSError + 152',Did you make it work ? I have the same issue.
Same to me, any update?
from react-native-sound.
Facing the same issue too; anyone found a solution? :/
@AnthonyLabaere @minhchienwikipedia ?
Right now I am starting to believe it is linked with NSAllowsArbitraryLoads / NSAppTransportSecurity config in info.plist, since this issue only happens on iOS with remote url.
If you guys wanna participate to the investigation...
from react-native-sound.
Now that's unfortunate; I am also using latest react native version (0.66)
Using react-native-sound 0.11.1
I am using audio files stored in firebase storage, in an .mp4 format.
Those audio files are beforehand recorded with 'react-native-sound-recorder'
I can open those files in my browser, and they play as expected
I am also using an empty string bundle path
It works perfectly on android, but not on iOS
I tried with different remote sound (if that matters, I tried with 'https://www2.cs.uic.edu/~i101/SoundFiles/ImperialMarch60.wav') and it works there.
Do you have any similarities here?
from react-native-sound.
My audio files are stored in Amazon S3
I use 'react-native-audio' to record files
I use the empty string, and it used to work before the upgrade (iOS and Android)
Now it works only on Android
from react-native-sound.
I have set 'NSAllowsArbitraryLoads / NSAppTransportSecurity' to false and even removed it on my Info.plist. But the problem persists
from react-native-sound.
Have you tried with the sample link I sent above if the audio played on your end?
If it does: then we are on the same boat.
If it does not work, then that means your problem is elsewhere in your code, in which case copy / pasting it here would be helpful for investigating
@OmarelBouari1 I might call you a bit late (5 years later :))
But I am facing exactly the same issue: ANY https link work fine, however as soon as it is a firebase storage one it crashes with the same error as you.
If you managed to find a fix since, I would love to hear it :)
from react-native-sound.
Okay some additional information following some investigation:
Any remote link that ends with a proper audi extension ( *.mp3, *.wav, *.aac etc) will be read without issue by react native sound.
However, as soon as we start playing with firebase / amazon url, that ends with a token and no file extension in their url, then the error happens.
So clearly ios or react native sound doesn't like an audio file without a proper url / extension...
And I still can't find my way around it.
Might need to first download the file with rn fetch blob, have a local url, and play it with sound then?
Ugly workaround since it works fine on android, but for ios this might now be required?
@minhchienwikipedia @AnthonyLabaere did you find a solution since?
from react-native-sound.
Nice one @minhchienwikipedia , good job on that.
I will give it a look later on; right now I found a "workaround" through a different plugin.
Since I have been using "react-native-audio-recorder-player" to record sounds, it so happens that they also can play sound, and they handle remote url perfectly fine, even when they are stored on firebase or amazon.
Thank you for your answer however, that might help some others!
from react-native-sound.
Hi @minhchienwikipedia,
Is it possible to increase audio speed with your package?
from react-native-sound.
Hi @pierroo, I had same issue with files from firebase storage. I solved it by a different approach:
import { utils } from '@react-native-firebase/app';
import storage from '@react-native-firebase/storage';
import Sound from 'react-native-sound';
[...]
const storageRef = '/audios/audio_test.mp3';
const filename = storageRef.split('/').pop();
const filePath = `${utils.FilePath.DOCUMENT_DIRECTORY}/${filename}`;
await storage().ref(storageRef).writeToFile(filePath);
const sound = new Sound(filePath, '', e => { if(e) console.error(e) })
Works on Android and iOS
from react-native-sound.
If you recently upgraded react-native-sound to 0.11.1+, the package added filepath encoding on the native side, so if you already have the sound files correctly in the Xcode resources folder, check if you had encodeUri
when defining your filepath and remove it. See info here
from react-native-sound.
@amed Had this problem. Solved it by adding Sound.MAIN_BUNDLE to the Sound constructor and moving the .mp3 files to the resources folder of the project in XCode.
(Note: Keeps working on Android without problems)
Constructor
var Beep = new Sound('beep_high.mp3', Sound.MAIN_BUNDLE);
If the folder does not exist, just create it, clean the project and then run again.
from react-native-sound.
Related Issues (20)
- setCategory() mixWithOthers boolean does not work HOT 3
- using new AvAudioPlayer feature fadeDuration issue. setVolume(1, {fadeDuration:3}) doesnt work it just plays at volume 1 immediately HOT 1
- Is there any audio puase/stop listener? HOT 2
- Fail to load sound in Android apk. { extra: -2147483648, what: 1 } HOT 1
- Audio plays as soon as an instance is created HOT 10
- Update import format to XCode 14.2 compat
- 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 1
- 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 1
- × 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 1
- Is there a software update plan? HOT 1
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.