I am having trouble figuring out how to manage a togglebutton that turns music on/off. When a user clicks it on, it should just loop continuously until it is turned off. I am using soundpool, if there was someway i could detect if my media was playing either by using soundpool or media player that would help. But i cant find anything relevant in documentation and similar question doesnt have a good answer; How to tell if a sound is still playing in soundpool
I have this so far:
final ToggleButton tglbuttn = (ToggleButton) findViewById(R.id.toggleButton1);
final SoundPool mySp = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
final int soundId = mySp.load(this, R.raw.music, 1);
tglbuttn.setChecked(????????); //what could go here?
tglbuttn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
If i could somehow get something like this bluetooth toggleswitch going, but with soundpool/mediaplayer, a way to tie in the actual status of media playing with the state of the togglebutton:
tglbtn.setChecked(myBluetooth.isEnabled());