Sound found but play() doesn't fire
See original GitHub issueHi there,
Just trying to implement a basic example with your component. Everything seems to be fine until I call play()
and then nothing happens. I’ve tried delaying the call with setTimeout()
but no luck.
Here’s my code:
componentDidMount: function() {
var snd_testShort = new Sound('mymp3.mp3', Sound.MAIN_BUNDLE, (error) => {
if (error) {
console.log('snd_testShort - failed to load the sound', error);
} else {
//all the file details come back and are logged...
console.log('snd_testShort - duration in seconds: ' + snd_testShort._duration +
' number of channels: ' + snd_testShort._numberOfChannels);
//the below line fires
console.log("snd_testShort - play attempt");
//I get nothing back from the `play()` call - I can breakpoint in XCode and the play method there fires without issue
snd_testShort.play((test) => {
console.log("snd_testShort - TEST");
if (test) {
console.log('snd_testShort - successfully finished playing');
} else {
console.log('snd_testShort - playback failed due to audio decoding errors');
}
});
}
});
As stated, in XCode I can step through the following in RNSound
(seemingly) without issue:
RCT_EXPORT_METHOD(play:(nonnull NSNumber*)key withCallback:(RCTResponseSenderBlock)callback) {
AVAudioPlayer* player = [self playerForKey:key];
if (player) {
[[self callbackPool] setObject:[callback copy] forKey:key];
[player play];
}
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
simple sounds will not play | Apple Developer Forums
I'm trying to play some simple interface sound effects, and the method I found online does not work. I don't get any errors...
Read more >Try These Fixes When Your Sound is Not Working in Chrome
1. Launch Chrome. 2. Click on the three dots (or three horizontal lines) in the upper right-hand corner of the browser. 3. Go...
Read more >PlaySound() mmslib does not play existing sound
This following code perfectly works: PlaySound(L"C:\\Windows\\Media\\Cityscape\\Windows Balloon.wav", 0, SND_FILENAME );.
Read more >Chrome Sound Not Working: 8 Fixes - groovyPost
If audio stops while using Chrome, you can take different troubleshooting steps. Here are eight fixes for Chrome sound not working.
Read more >Audio Not playing in Unity at all. [SOLVED] - Unity Forum
Hi tmanallen, does preview playback of sounds work in the editor? ... I have to try that, but it doesn't play in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found the same thing after a recent upgrade to the module. It appears you have to call .play() now inside the callback function passed to the Sound constructor. e.g.
old code (no longer works… if you console.log(sound) you will see that sound._loaded == false)
New code (works):
This should be made more clear in documentation