Notify that app is playing sound when in the background


#1

I’m developing a music app. How would you go about telling the user that your app is playing sound when it’s not on focus? I’ve managed to make cordova local notifications work, but I can’t figure out how to show the notifications only when the app is in the background or the phone is turned on, just to allow the user to return to the app to turn the damn sound off (I imagine the users hating the app for not providing a way back) or, hopefully, to continue to interact with the app.

Thank you for your attention!


#2

Well, I managed to make it sort of functional, and it was easier than I expected. I used a $watch to trigger a new notification when a track is loaded into the player. I still would like to get rid of the led blinking when the phone is on standby, but there doesn’t seem to be a way to do that with cordova local notifications. Still, developing with Ionic is awesome and a lot of fun for an almost-illiterate-as-a-programmer musician like myself. Thanks!


#3

Please how did you get it to play sound, this is my code
$cordovaLocalNotification.add({
id: “1234”,
date: alarmTime,
message: “This is a message”,
title: “This is a title”,
autoCancel: true,
sound: ‘/www/sound.mp3’
})
i have tried assests/www/sounds.mp3, it still didnt play the sound on android but notification works fine