Software Archive
Read-only legacy content
17061 Discussions

Bug: Inserting custom sound file into project

Phil_P___Pete_
New Contributor I
530 Views

I've created the custom plugin to copy custom sound files into the project.

Because the sound files are NOT playing I've been doing some research and there's about a dozen suggestions on where to put those sound files. I decided to try the three most popular locations.  I removed the custom plugin from the project (a necessity) and then added it back in with the new file locations as shown below:

<?xml version="1.0" encoding="UTF-8"?>  
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="sounds-phonegap-push-plugin" version="1.0.0"> 

    <name>Adding custom sounds to Phonegap XDK builds</name> 
    <description>Add customized sounds to XDK phonegap builds.</description> 
    <license>MIT</license> 

    <engines> 
        <engine name="cordova" version=">=3.0.0" /> 
    </engines>  

    <!-- android --> 
    <platform name="android">        
        <!-- Replace *.wav with your own sound files -->
        <resource-file src="snd/eas.wav" target="res/raw/eas.wav" />
        <resource-file src="snd/bwerp.wav" target="res/raw/bwerp.wav" />
        <resource-file src="snd/eas.wav" target="www/res/eas.wav" />
        <resource-file src="snd/bwerp.wav" target="www/res/bwerp.wav" />
        <resource-file src="snd/eas.wav" target="/eas.wav" />
        <resource-file src="snd/bwerp.wav" target="/bwerp.wav" />
    </platform>  

    <!-- iOS --> 
    <platform name="ios">
        <!-- Replace *.wav with your own sound files -->
        <resource-file src="snd/eas.caf" target="/eas.caf" />
        <resource-file src="snd/bwerp.caf" target="/bwerp.caf" />
        <resource-file src="snd/eas.caf" target="www/eas.caf" />
        <resource-file src="snd/bwerp.caf" target="www/bwerp.caf" />
        <resource-file src="snd/eas.caf" target="www/res/eas.caf" />
        <resource-file src="snd/bwerp.caf" target="www/res/bwerp.caf" />
    </platform>  
</plugin>

Several people have said that the custom sound files have to be in the root (above www) for ios.  How does one get those files there? What would be the appropriate path?

I decided to experiment... 

If you look at these two lines:

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

One would "think" that using a plain / would indicate the project root. But apparently this creates an issue with XDK when it tries to import the .wav file and gives the error that C:\eas.wav is not in the project.  Not sure where it came up with that path but that path is NOT referenced in my project at all.

Now, oddly, if you remove those two lines and ONLY those two lines (which means leaving those same two lines in for iOS) you'll find it adds the plugin just fine.

Not sure why it would add a .caf file (if it did) in iOS but not add a .wav file to Android. Either way, the error message is completely wrong.

0 Kudos
7 Replies
Phil_P___Pete_
New Contributor I
530 Views

As an added note:

The iOS build will fail on any path except www/res (the last two). 

        <resource-file src="snd/eas.caf" target="/eas.caf" />
        <resource-file src="snd/bwerp.caf" target="/bwerp.caf" />
        <resource-file src="snd/eas.caf" target="www/eas.caf" />
        <resource-file src="snd/bwerp.caf" target="www/bwerp.caf" />

        <resource-file src="snd/eas.caf" target="www/res/eas.caf" />
        <resource-file src="snd/bwerp.caf" target="www/res/bwerp.caf" />

 

0 Kudos
PaulF_IntelCorp
Employee
530 Views

If I recall correctly, your custom sound files are meant to customize the sounds in the phonegap-plugin-push notification plugin. Doing a quick search, I find some instructions that work nicely for PhoneGap Build, but that requires a custom build preference, for which we do not have an equivalent. See this thread > https://github.com/phonegap/build/issues/401#issuecomment-156277041 < which came from here > https://github.com/phonegap/phonegap-plugin-push/issues/555 <

Based on the info here > https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#ios-behaviour < which jives with what you stated above, I don't think there is a way to make this work with our build system, on iOS. When they are referring to the "root of your project" they are speaking in the context of a Cordova CLI project. Our system sends the www, package-assets, and plugins folders, along with the config files located in the root. Nothing else gets sent to the build system, so even though the "root" of your XDK project corresponds to the root of the project that is assembled in our build system, the files contained in that build system root project are not duplicated from your local app project.

Unfortunately, I believe there is no way to specify copying something into the root of your project using the Cordova plugin directives, which is why the process is described (in the link above) as a manual one. The only way to do this would be to use some hooks scripts, but our build system disallows those, for security reasons (as does, I believe, PhoneGap Build).

So the only option I see is using Cordova CLI (or PhoneGap CLI) to build your app locally, because then you will have full access to the complete Cordova project folder and sub-folders and can do exactly what is being described.

Sorry, but the nature of our build system does present obstacles for some situations, and this sounds like one of them.

0 Kudos
Phil_P___Pete_
New Contributor I
530 Views

Paul,

I found that inside the Payload/AppName which is the project root... the .caf files are correctly located.  They are also in www/res and still no sound... sigh...

Also, even skipping over the iOS issues, you still have the issue with the .wav files on Android and that C:\ error message

0 Kudos
Jerroyd_M_Intel
Employee
530 Views

Hi Phil,

You've piqued my interest in the path resolution problem you've posted. It prepended "C:\" to your paths during an android or a windows build? If you're attempting an android build, this would indicate to me that bug is part of Cordova. We could modify the Intel XDK build system to perform a cursory check, but ultimately, Cordova may not support absolutely paths. If you're performing a windows build, this may be indicative of a bug in the Intel XDK build system.

Are you publishing your plugin for general use? If so, I would like to experiment with your plugin.

--Jerroyd

0 Kudos
Phil_P___Pete_
New Contributor I
530 Views

Create a project, create a plugin using the code and settings I documented and build.

You'll see the bug.

On a related note, the iOS build really doesn't seem to care what path you use outside of www as it sticks the sound files in the root thereby ignoring the designated/directed folder.

IOW the ipa is structured as:

Payload->MyApp.app-...

If you specify the destination as Payload/MyApp.app/blah you hit problems.

0 Kudos
Jerroyd_M_Intel
Employee
530 Views

Thanks for the update Phil.

It sounds like it is a bug with Cordova. After I reproduce it, I'll submit a bug report to Apache.

--Jerroyd

0 Kudos
wei_j_2
Beginner
530 Views

Hi, may I ask what is the conclusion of this issue?

where should I put sound files for ios, and how to write the path in plugin.xml(or config.xml)?

Thanks!

0 Kudos
Reply