I want to lower the ringtone, media volume, and alarm volume from an app (button press, no slider). So I've been reading up on AudioManager , but I'm still a bit confused on how to do this.
Also, with Audio Manager, is the volume set for the whole phone or just for the app? I want it to be for the whole phone
but I'm still a bit confused on how to do this
Call adjustStreamVolume() with your desired stream (e.g., STREAM_ALARM) and change (e.g., -1). Here is a sample project that demonstrates this.
is the volume set for the whole phone or just for the app?
Android does not have a concept of app-specific volume, so this is for the whole phone.
Related
So using openvidu to setup two way calling but I noticed an issue when it’s being used on an android device.
The android phone has multiple volume controls, one of them is the media volume, so if the user watching as a subscriber has their media volume low they can’t hear the publisher speaking until they turn it up, and a few people don’t even know this exists.
By default the volume up hardware button seems to control the phone volume, or rather it seems to control the last one that was used.
It’s a little concerning that many people won’t know about this and will complain they can’t hear anything, unlike on the iPhone where the one button controls the overall volume.
I doubt this is possible but are we able to increase the android media volume
With JavaScript somehow? I very much doubt it but I’m not sure how to solve this problem if we can’t. I know we can control the video element volume itself but that seems to have no impact on the phone volume itself. As in I can turn the phone media volume all the way up but control the video element separate instead of them working together.
How can I control the volume of a background sound?
I'm making a game, and in some states I want to increase or decrease the background sound.
I have tried some things with MediaPlayer and SoundPool, but it did't do what I wanted.
I dont want to change the phone volume, but the volume of the sound. Is this possible? If yes how?
Cheers
You haven't told use what "some things with MediaPlayer and SoundPool" means, or shown us any code, so it's hard to say exactly what the problem might be.
If you want to make the volume keys modify the volume of your app's music rather than the voice call volume, you might be missing a call to setVolumeControlStream (e.g. setVolumeControlStream(AudioManager.STREAM_MUSIC);).
Refer to "Controlling Your App’s Volume and Playback" in the Android developer documentation for more information.
If you're using the MediaPlayer setVolume method, then keep in mind that the maximum volume you can set is 1.0 (i.e. the original volume of the audio data you're playing).
I have developed game in unity3d.
In that game, i have given option for setting sound volume sound which affects my game sound object only, This does not relate with the android sound setting.
But i just want to check whether my android device is set to mute or not. If my device setting is mute then i will keep my game sound volume size value to 0.
But i am not getting the way to find the android device sound status,..if anyone is having idea then please guide me.
Thanks in advance for your support and help..
You can get the level of sound from your device this way:
AudioManager manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
int levelSound = manager.getStreamVolume(AudioManager.STREAM_MUSIC);
You need to know the stream you are using, normally Music for any multimedia sound (music, games, films, etc...)
You can check also this, to know the mode of the phone right now:
manager.getRingerMode();
Google docs states if an app isn't playing anything, hitting the volume keys adjusts the ringer volume.
see http://developer.android.com/training/managing-audio/volume-playback.html#HardwareVolumeKeys
I'm sure it is possible to change this 'default' behavior something besides STREAM_RING (say STREAM_MUSIC) by creating custom build from source, so that if the user is at, say the Launcher, and presses the volume button the the STREAM_MUSIC volume will change.
(This require is because the device doesn't have a phone so ring volume is a no-op).
I've looked at the Launcher code but it doesn't show (at least not that I can see) that volume buttons are directed/consumed via AudioManager to STREAM_RING.
Also when in 'Settings' the VOLUME buttons change STREAM_RING, which leads me to further believe there is something 'Up the chain' or 'Down the stack in Application Frameworks or in the Android Runtime'.
Is there a 'higher' Activity or system process running that handles the dispatch of VOLUME to the AudioManager with the STREAM_RING as the channel?
Or is there something within AudioManager that could be set so that it processes VOLUME changes to the STREAM_MUSIC (this seems unlikely from the source as it appears to only process the STREAM in the context of an applications preferred STREAM.
The source I'm using is Ice Cream Sandwich 4.0.3.
The solution appears to be setting "config_voice_capable" to false.
This value is found in frameworks/base/core/res/res/values/config.xml
I used an overlay to set the "config_voice_capable" to false, then built the rom.
After the device boots the volume controls no longer default to the RINGER stream.
I was not able to find documentation on this regarding differences between
tables and phone capable devices, but the solution works.
In General, JAVA based android app development. we may use...
setVolumeControlStream(AudioManager.STREAM_MUSIC);
So that activity makes volume controller to control MEDIA Volume.
If I want to achieve this in Adobe Air based android app.
How do I do that?
How about building an AIR native extension to interact with the system volume for Android.
Like: https://github.com/nweber/SystemVolumeNativeExtension
Related Explanation article: http://www.adobe.com/devnet/air/articles/building-ane-ios-android-pt1.html
Expected behaviour from the github readme
When changing the volume using the hardware volume keys the system
volume popup will be displayed. The AIR application will be notified
of the new volume after the system volume popup disappears. This
means that the user can press the hardware volume buttons several
times before AIR is notified of a volume change. When changing the
volume from AIR the system volume is changed, but the system volume
popup is not displayed.