Sound control java + ndk

All your problems with Audio, Video and Images.

Sound control java + ndk

Postby timoshenko_av » Thu Jan 20, 2011 2:03 pm

Hello!
Before startings my ndk part of application i remember old volume state and set it to maximum(i do this because i want sdl control sound volume without limits),
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. AudioManager am = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
  3. int oldMusicVolume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
  4. am.setStreamVolume(AudioManager.STREAM_MUSIC, am.getStreamMaxVolume(AudioManager.STREAM_MUSIC),0);
  5.  
  6.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


and when ndk close restore old music volume
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. am.setStreamVolume(AudioManager.STREAM_MUSIC, oldMusicVolume,0);
  3.  
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


If my app unexpectedly terminate, and i dont restore old sound volume users settings will be lost.
Does someone know how can i implement this feature using another more properly way?
Much thanks!
timoshenko_av
Freshman
Freshman
 
Posts: 8
Joined: Tue Oct 05, 2010 10:02 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 16 guests