Software Archive
Read-only legacy content
17061 Discussions

What's the easiest way to put a sound file in res/raw?

Phil_P___Pete_
New Contributor I
561 Views

Ok, so I've read all the stuff around and the suggestions simply aren't working.

I've started here and gone through this and every other option: https://software.intel.com/en-us/forums/intel-xdk/topic/680309

Here's what I've done last:

I downloaded the phonegap-plugin-push and removed the gradle stuff. I created a directory inside that called snd and it's on the same level as src. Inside the plugin.xml file I have found the platform sections for android and ios. Inside the platform tag (android or ios) I add this:

    <resource-file src="snd/eas.wav" target-dir="res/raw/eas.wav" />
    <resource-file src="snd/bwerp.wav" target-dir="res/raw/bwerp.wav" />

I can build and build and build and build and no matter what I do, those files do NOT end up in res/raw... in fact, res/raw doesn't even get created.

Of course this completely kills the whole custom sound on push notification process.

Also, I could find no documentation on where those sound files go for ios... certainly it's different. 

So how do we get these sound files embedded in the correct location in the app?

 

0 Kudos
6 Replies
PaulF_IntelCorp
Employee
561 Views

Phil -- rather than modifying the phonegap-plugin-push, try creating a local custom plugin, as Frungh did here > https://software.intel.com/en-us/forums/intel-xdk/topic/680309#comment-1883224 < then add that plugin to your project using the local import method (see the image below).

Screen Shot 2016-11-21 at 9.31.08 PM.png

0 Kudos
Phil_P___Pete_
New Contributor I
561 Views

I think the issue might be that XDK imports and once imported it ignores any changes to the plugin.  I suspect the solution would be to remove the plugin and then reimport it and I suspect that the same issue will apply with using the custom sound plugin and adding new sound files and or changing the existing sound files.

Also, where do we put the ios files? Also in res/raw?

0 Kudos
PaulF_IntelCorp
Employee
561 Views

Phil -- the plugins folder gets pushed to the build system, which then performs a new "plugin add" based on the build settings and the contents of that plugin folder, so technically, changes you make in there should stick, but only if you update the plugin.xml file as part of those changes. Generally, from a documentation and implementation perspective, creating the separate plugin works better, it allows you to update the base plugin without having to go back and edit it and clearly documents what you have done (assuming you keep the special plugin as part of your project sources).

Not sure where it goes in the iOS system. iOS apps have a different layout, you'd have to look at the specifics of that plugin to understand where that file should go in an iOS build. Note that Cordova creates an Xcode project (for iOS) and so the net result of any plugin has to satisfy the requirements of an Xcode iOS project. (In other words, res and raw are specific to an Android Studio project, they have nothing to do with Cordova or HTML5.)

0 Kudos
Phil_P___Pete_
New Contributor I
561 Views

I've experimented with this.  Just adding two sound files to the push-plugin only gets those sound files installed when you remove the plugin and the re-add it... simply updating the plugin.xml does nothing.  I tried various <resource-file and <source-file etc. 

If changes "should stick" then I'm guessing the build system isn't detecting a date/time change in the plugin.xml and acting accordingly.

The sound files are there now using the Frungh plugin.xml.

0 Kudos
PaulF_IntelCorp
Employee
561 Views

There's an optimization regarding pushing plugins to the build system that I forgot about, where it tries to minimize the number of times a plugin needs to be sent to your account. That could be interfering with changes to the /plugins folder. The best approach is to do what you've done (add a plugin) or make a custom version of a plugin and then add that to your project. Editing plugins once they are in the /plugins folder is not a good option.

0 Kudos
Phil_P___Pete_
New Contributor I
561 Views

Just as long as everyone realizes that if you modify plugin.xml (such as adding a new sound file or changing the name or destination of a sound file) that the developer has to remove the plugin from his/her project and then re-add that plugin in order for changes to take effect.

I would be much easier if we could just add the info to config.additions or via the UI the same way we add icons and splash screens.

0 Kudos
Reply