i am trying to make kind of player, so, I setup play button and pause button and make them clickListener . when i press play button the thread start (and it work fine) but the pause button dont work until the thread is finished. what can i do to fix it?
constructor:
play = false;
playButton=(ImageButton)findViewById(R.id.imageButton1);
playButton.setOnClickListener(playButtonClick);
the runnable:
private Runnable runnable=new Runnable() {
@Override
public void run() {
int count=0;
long time=System.currentTimeMillis();
while(count<24*3 && play)
{
if (System.currentTimeMillis()-time>41.67){
count++;
time=System.currentTimeMillis();
scene.play();
draw(sf.getHolder());
}
}
play=false;
}
clickListener:
private OnClickListener playButtonClick=new OnClickListener() {
@Override
public void onClick(View v) {
if (!play){
play = true
scene=new TestScene(3,t);
thread=new Thread(runnable);
thread.run();
}else
play = false;
}
};
the problem: when the thread is run i cant stop it the function clicklistner is working just when the thread is stop.