Spotify stops playing when launching my Ionic App - android

I am building an alarm ionic app that load custom sounds according to my preference and using the NativeAudio component.
The alarm is intended to just give me a buzz on specific times playing some voice recorded reminders. So when I listen to spotify and the alarm fires, it should put spotify music on hold and plays it back after the alarm.
I know we cannot control the spotify app from an outside app. However, I noticed that when I video in facebook, spotify stops, and after the video, spotify resumes.
Any guide on how to do an ionic app with this behavior would be appreciated.
Thanks!

Related

ionic play sound on websocket message in background

I am working on an Ionic app, that connects with websocket server and when the app receives new message I want to play audio in a loop till user reacts to it.
All of that works when the app is open. When the app is in the background (or the phone is locked), the sound is not played (either this or the message is not received at all).
Basically, I want similar behaviour to the Meta's Messanger app.
How can I achieve that? I guess I lack some basic mobile app development knowledge, because I do backend on daily basis.
I am developing it for Android.

How can Android playback streaming audio by push notification trigger?

I'm an iOS app developer and not familiar with Android. I'd like to implement the feature that playbacks audio over the internet when the mobile receives a push notification.
I've investigated it for iOS and concluded that it is impossible in iOS because Apple prohibits downloading data over the internet in background from being developed.
I'd like to know if this feature is feasible or not in Android. Could you give me any advises ?
You need to implement PendingIntent to get you notification and start ForgroundService or this or this to play your audio and close it when the user leaves your app or while they are using your app depending your particular needs.

notification sound not working when video is recording

In my app, the user have an option to record video. While the user is recording video, if the app triggers a local notification, the notification sound is missing.
But apps like Hangouts, System alarm etc. are able to trigger a notification with sound.
Tried setting notification priority to maximum, requesting audio focus but no luck.
notificationBuilder.setPriority(2);
notificationBuilder.setSound(soundUri, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
Is there a way to trigger a notification with sound, when camera recording is on ? Or is this the default behaviour ? Workarounds ?
Environment: Nexus 7, Android 6.0.1
PS: Whatsapp is able to generate notifications with sound on One Plus 2(Android 6.0.1) when video recording is on.

Android Play background sound

I am going to create call record application, There I need to play minute and recording notification sound. It should here to caller and receiver two parties. Is there any good example for such application?
Thank You.
I am going to create call record application
That is not possible on Android. Android SDK applications do not have access to the in-call audio.

Pause/resume mediaPlayer on notification sound

It's easy to detect when phone calls come in (via phoneStateListener), but what about other notification sounds, such as email or sms?
On some devices, these notification sounds mute but don't pause any currently running mediaPlayer instances, which is annoying for the user. Ideally, I'd like to listen for notifications that play sound, pause playback for the duration, and then resume playback afterwards.
You can get notified when another app wants to play audio by registering a callback on AudioManager.OnAudioFocusChangeListener (this would also handle the case of an incoming call). Specifically, you can look for AUDIOFOCUS_GAIN, AUDIOFOCUS_LOSS, and AUDIOFOCUS_TRANSIENT_LOSS. The Android music player source has a good example of this.

Categories

Resources