Skip to content
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

android: local sound file is not played #24

Closed
amunters opened this issue Dec 8, 2013 · 9 comments
Closed

android: local sound file is not played #24

amunters opened this issue Dec 8, 2013 · 9 comments

Comments

@amunters
Copy link

amunters commented Dec 8, 2013

Thanks for this great plugin! However, I encountered one issue with Android: When I specify a custom notification sound, it works OK when I specify a sound file on a remote location, i.e. sound: 'http://example.com/sound.mp3'
But when I specify a local sound file it doesn't work. No sound, no error messages either. My sound file is located in the top www directory. I tried many ways to specify the location, but nothing works:
sound: 'sound.mp3'
sound: '/sound.mp3'
sound: 'www/sound.mp3'
sound: '/www/sound.mp3'
sound: 'android_asset/www/sound.mp3'
sound: '/android_asset/www/sound.mp3'
sound: 'file://sound.mp3'
sound: 'file:///sound.mp3'
sound: 'file://www/sound.mp3'
sound: file:///www/sound.mp3'
sound: 'file://android_asset/www/sound.mp3'
sound: 'file:///android_asset/www/sound.mp3'

I this a bug, or am I doing something wrong? Please advise

  • thanks, Allard
@katzer
Copy link
Owner

katzer commented Dec 8, 2013

Hello Allard,

move the sound.mp3 to res/raw. On Android images or sounds must be placed into the res-folder.

sound: "android.resource://" + package_name + "/raw/sound"

@katzer katzer closed this as completed Dec 8, 2013
@amunters
Copy link
Author

amunters commented Dec 9, 2013

Thanks, that's useful information - it works OK now! I also noticed you updated the readme file accordingly - it is more clear now, Many thanks again.

@rodolphorosa
Copy link

I also had this same problem. When I specify the location of a mp3 sound, it's simply not fired. I've tried this, but it's not working:

window.plugin.notification.local.add({
        id:      1,
        title:   'Lembrete',
        message: 'Sua coleta chegou',
        repeat:  'minutely',
        sound: 'android.resource://res/raw/ringtone',
        date:    _60_seconds_from_now
    });

@amunters
Copy link
Author

amunters commented Apr 1, 2014

Hi Rodolphorosa,
you need to specify your package name instead of 'res',
see below how I got it working in my app:

         window.plugin.notification.local.add({
             id: '1',
             title: 'EsSense',
             message: 'E-skip / TEP NOW!!',
             ongoing: true,
             icon: 'red48',
             sound: 'android.resource://net.gooddx.essense/raw/ess'
             });

@rodolphorosa
Copy link

this is the package name of your application?

@amunters
Copy link
Author

amunters commented Apr 1, 2014

yes!

@rodolphorosa
Copy link

thanks, it worked!

@Riyaz0001
Copy link

Riyaz0001 commented Apr 20, 2017

hey guys, the same problem, sound not played in my real android device version 4.4.2
my code is:

cordova.plugins.notification.local.schedule({
                    id: 1,
                    text: 'Scheduled every minute',
                    every: 'minute',
                    sound: "android.resource://com.test.notificationapp/raw/sound",
                    icon: 'res://icon',
                    smallIcon: 'res://ic_popup_sync'
                });

how to solve this problem? anyone help please, Thanks.

@rwillett
Copy link
Collaborator

Don't hijack closed threads that are over three years. Raise a new issue with the template in #1188.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants