In my app, I would like to play audio. As long as my app is actively running, no other audio from any other apps should be played. I.e. no push audio notifications (e.g. WhatsApp), no call ringtones, no SMS, or anything else. Only my app should be able to play unmuted audio.
So whenever my app is running, the whole OS and the background apps should be muted, even if my app is currently not playing any audio. Is that possible?
Related
I need to develop an app in which my main activity should open automatically whenever I receive an incoming call(whether my app is on background, foreground, killed or even my phone is locked).
Can anyone help me with source code or guide me to develop this app?
how to check which app/packages is using internet, camera, and mic in the background? basically, I want to develop an app which checks the background running app, is that any app which is using internet, mic, and camera in background and giver user an option to close that app? any solution in android studio..?
I have a VideoView without any audio playing every time I start my app. I have noticed that when it starts playing, music playing from other apps in the background pauses. Is there any solution to this? Thank you!
Playing video while background music playing is not recommended:
To ensure a great user experience, it’s also important that your app manages the audio focus to ensure multiple apps aren’t playing audio at the same time.
You can check this for more information.
When you start play video using VideoView, you app request the audio focus, this mean the background app which is playing music lose the audio focus. The background app's behavior depends on the code in AudioManager.OnAudioFocusChangeListener.OnAudioFocusChangeListener method. You can not change it.
More information, see Managing Audio Focus.
I am making an app for Android Wear Devices that don't have speakers. For now I am testing. How can I make it so when you tap "button1" it does said function that plays, say an MP3 file FROM THE PHONES SPEAKER.
You'll need to build out a companion phone app to play the sound, and trigger it from Wear, probably using the Message API. The FindMyPhone sample (linked from that doc page) is probably a good place to start, as it's doing something quite similar to your requirements: playing a sound on the phone, triggered by an action on the watch.
not sure if this is possible, I have an icecast server configured and streaming music, and I want to create a web player using Java (or grails). I managed to get the java web app playing the music icecast is streaming, using something like this:
AudioInputStream stream = AudioSystem.getAudioInputStream(new URL("http://localhost:8000/musicstation"))
and after a few more lines the music is playing, the problem is that if I close the tab with the web app the music keeps playing, I have to stop the application to stop playing, but when I start it again and try to play again, it's like the icecast server continued playing the song in the background, I mean, it didn't stop or paused, because of this I cannot implement a pause action, since if I pause, what it actually be paused will be the web app playing the song, but in the background icecast will continue transmitting the song, so that when I play again after paused, the song won't continue from the point it was paused.
Is using AudioInputStream the correct way to implement an icecast audio client?
I hope I could explain myself.
thanks
Icecast obviously continues to "play", since it is a live streaming server. If you want to implement a pause mechanism, you need to buffer what you get from Icecast and play the buffer.