I make a android application for play sound.
I use the service for playing sound, however when close the app service stopped then music stopped.
Please help me
Related
When the app is in background and receive a notification I play a audio with the help of broadcast. But I am not able to stop the playing audio after getting into the application. Please help..
Is there a possibiltiy to detect which app is sending sound? I only found a solution to recognize there is sound playing, but not which app is playing it.
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!
I am creating an application in which in have to detect music player states like playing, pause, stop.
i searched and found
AudioManager manager = (AudioManager) FlashLightActivity.this.getSystemService(Context.AUDIO_SERVICE);
if(manager.isMusicActive())
{
Toast.makeText(FlashLightActivity.this, "Music is playing..", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(FlashLightActivity.this, "Music has stopped..", Toast.LENGTH_LONG).show();
}
By using above code i am not able to detect music state if my application is in running mode.
Above code will check this condition at starting of the application. i wanna use broadcast receiver for detecting the state of background music.
Above code will check this condition at starting of the application
I will be stunned if it does so reliably. There is no requirement that any app tell AudioManager that it is playing music.
i wanna use broadcast receiver for detecting the state of background music.
There are thousands upon thousands of music players available for Android. There are no requirements that any of them implement broadcasts to tell you of the state of music playback. There are not even some standard broadcasts in the SDK that you could reasonably hope that some of those players might use.
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.