Android: Play / Pause song on proximity sensor method
Is there any way to play and pause the song using proximity sensor? I
wanted to play the song as default state. When a user waves his hand over
the proximity sensor, it should pause the song till the time he waves
again.
I have these code which pause when you in near / far state. It start
playing on far / near value. I wanted to make is pause for the same event
and then play for the same event next time.
if(event.values[0]==sensor.getMinDelay()) or
sensor.getMaximumRange()
{
Log.i("Pause","Pause");
player.pause();
textView.setText("Pause");
}
else
{
Log.i("Play","Play");
player.start();
textView.setText("Now Playing..!");
}
Any help / Suggestions is appreciated.
No comments:
Post a Comment