How do you change the volume of a sound?

All your problems with Audio, Video and Images.

How do you change the volume of a sound?

Postby emadeva » Wed Sep 07, 2011 5:31 pm

Hi Everyone,

I'm using this code to play a sound.

I would like to give the user the ability to alter the volume of the sound. Can you tell me how to do this?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. NotificationManager nm = (NotificationManager) context
  2.                                                 .getSystemService(Context.NOTIFICATION_SERVICE);
  3.                                 Notification notification = new Notification();
  4. notification.sound = Uri.parse("android.resource://emad/raw/quarter");
  5.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Thanks.

Truly,
Emad
emadeva
Junior Developer
Junior Developer
 
Posts: 19
Joined: Wed Aug 24, 2011 7:37 pm

Top

Re: How do you change the volume of a sound?

Postby khaitt » Thu Sep 08, 2011 11:32 am

You can use AudioManager to solve this problem
khaitt
Freshman
Freshman
 
Posts: 6
Joined: Sat Feb 26, 2011 5:32 am

Re: How do you change the volume of a sound?

Postby emadeva » Thu Sep 08, 2011 11:39 am

Hi khaltt,

Can you show some sample code to do it?

Thanks so much.

Truly,
Emad
emadeva
Junior Developer
Junior Developer
 
Posts: 19
Joined: Wed Aug 24, 2011 7:37 pm

Re: How do you change the volume of a sound?

Postby ramesh.kec.85 » Mon Sep 12, 2011 5:40 am

I think that help this code for you..
AudioManger mAudioManager = (AudioManager) this
.getSystemService(Context.AUDIO_SERVICE);


Create a seekbar to handle media volume.

public void onProgressChanged(SeekBar sBar, int progress,
boolean fromUser) {
volume_seekbar.setProgress(progress);

mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,
progress, 0);
}
Thanks

Regards
--R@mesh
ramesh.kec.85
Developer
Developer
 
Posts: 27
Joined: Sat Jul 30, 2011 10:05 am
Location: Ahmedabad

Re: How do you change the volume of a sound?

Postby emadeva » Mon Sep 12, 2011 9:50 am

Hi Ramesh,

Thanks so much for the help and code examples. It will help a lot. :-)

Truly,
Emad
emadeva
Junior Developer
Junior Developer
 
Posts: 19
Joined: Wed Aug 24, 2011 7:37 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 10 guests