-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "requiring" audio files via RN assets system (iOS only) #47
Conversation
@@ -64,25 +64,6 @@ -(NSDictionary *)constantsToExport { | |||
[session setActive: enabled error: nil]; | |||
} | |||
|
|||
RCT_EXPORT_METHOD(setCategory:(nonnull NSNumber*)key withValue:(NSString*)categoryName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't remove this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't meant to remove this. I added it back in the 2nd commit.
Thanks for the patch! |
I'm unable to get this to work. It didn't work in my project, so I tried in react-native-sound-demo. I used:
I'm using master (530a5d3)
|
This addresses #14 for iOS by adding support for using the RN assets system to
require
audio files that are placed alongside your JS components. I also fixed a bug where the iOS implementation wasn't correctly handling file paths that included URL encoded values (e.g.%20
).Additionally, I modified the
Sound
constructor signature to allow omitting thebasepath
argument if an asset value was specified, so that the following syntax can be achieved.This PR currently only supports iOS, since the RN packager places the audio files into the
drawable-mpi
directory, as opposed toraw
(where this plugin expects to find them) when generating an Android bundle. In general, the asset system on Android doesn't seem to really accommodate non-image assets at the moment. I'm going to investigate this and likely send a PR to RN itself, but I wanted to get this PR out to start the conversation.I've got a local fork of RN that correctly writes audio files to the
raw
directory, and with this PR,react-native-sound
works perfectly, so this PR should accommodate both iOS and Android, yet I'll need to submit a fix to RN to actually do the right thing for Android.NOTE: As an aside, this PR also allows you to ship updates to your audio files via OTA update services (e.g. CodePush), which is pretty awesome.