Showing posts with label set mediaPlayer Volume dynamically while playing sound. Show all posts
Showing posts with label set mediaPlayer Volume dynamically while playing sound. Show all posts

Saturday, May 11, 2013

[android help] set mediaPlayer Volume dynamically while playing sound


I am having an application in which I am playing a sound with the help of MediaPlayer in a service,which is running properly. But what I want is to set the volume of the sound with the help of seekBar or something dynamically while the sound is being played. The code is as follow:


PlayerActivity:



public void onClick(View src) {
switch (src.getId()) {
case R.id.buttonStart:
Log.d(TAG, "onClick: starting srvice");

startService(new Intent(this, MyService.class));
break;
case R.id.buttonStop:
Log.d(TAG, "onClick: stopping srvice");

stopService(new Intent(this, MyService.class));
break;
}
}


MyService.java



@Override
public void onCreate() {
player = MediaPlayer.create(this, R.raw.sound);
player.setLooping(false); // Set looping
}

@Override
public void onDestroy() {
player.stop();

}

@Override
public void onStart(Intent intent, int startid) {
player.start();
}


How would I set a seekbar and set the volume of sound while it is playing. Thanks.



.

stackoverflow.comm

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...