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.
Related
I am developing an App, which can play a tone at a fixed frequency to the users by using the Audiotrack Java class. Now the sound can be played when a button is pressed, I want to keep the sound keep playing when the screen is off, because the users may want to listen to the sound for 20 minutes at night where doesn't require the screen on all the time. Anyone can help with this?
I have tried the WakeLock according to other posts on Stack overflow, but it doesn't work. when I go to the activity, the app stops and quits.
To keep sound playing when the screen is off, use a foreground service to play the sound and when the user clicks the start button, you should start your service
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?
New to Android Studio and android programming, I have looked here and the rest of the web but not been able to find a solution.
I am using viewflipper to create a slide show with next and previous buttons, this works just as it should. With each new image the user can touch the screen and get a short audio playback about image. There are 32 images for the first 15 all works well but after that the audio playback part stops working.
Is there a way to set mediaplayer to play all 32 if required or does the media player have to be reset after each playback.
I am using an onclick method to play the sound, I do not want to place more buttons on the screen to reset the player, also if the user touches the screen after the initial playing of the audio then the audio will play again.
Is what I am trying to do possible
I began creating an app that will run in the background and globally repurposes the play/pause/forward/backward buttons to change the volume which is intended to apply to any media player.
Example: While streaming media in Pandora or Youtube, pressing pause will
lower the volume then activate pause and pressing play will increase the volume then activate play.
I find that onMediaButtonEvent() will give me a similar effect except that this is localized to only within the app it is written in and applies to only physical hardware play/pause/forward/backward buttons.
Also, I can use onClick() which allows me to decide what happens when a play/pause/forward/backward button is pressed but this is limited to within the app.
Can anyone offer any insight on if there is another function, a work around or if this is even possible? Maybe i am looking in the wrong direction and there is something that needs to be modified in the kernel which is out of bounds.
I was wondering what the best way to do this is. What I'm hoping to do is have a user push a button and automatically take a 10 second video, then save it to the SD card. I've seen how to do it through creating a new Intent, but the user then has to do the extra step of pushing record after selecting that they want to go to video. My goal is for them to push one button--one in my app that says "record", have it start recording for 10 seconds, then stop and save. In addition, I'd like to have some code executing in the background without being interrupted during said recording. What is the best way to do this?
Opening the camera with an Intent is simply opening the system camera app to take a picture/video. For more advanced usage, you can control the camera directly. Full details are in Controlling the Camera (from Android Developers).
You should make a service for that.