Monday, July 19, 2010

[android-developers] How to respekt volume preferences ?

Hello,

i have Code which plays a notification sound using the MediaPlayer :

AssetFileDescriptor afd = null;
try
{
afd = getContext().getResources().openRawResourceFd(_resourceID);
player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(),
afd.getLength());
player.setVolume(VOLUME, VOLUME);
player.prepare();
player.start();
...
...


How can i respekt the Volume Settings of the User ? VOLUME is set to
1.0f there.

I thought it would possible to read the Volume using the AudioManager,
but it will return an integer:

final AudioManager audioManager = (AudioManager)
_context.getSystemService(Context.AUDIO_SERVICE);
final int volume =
audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION);


Thx,
Jens


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate