How To Play Sound By Ontouch And Stop When Fingures Up
When I touch on Image, the media player starts but on removing fingure from that image, media playes does'nt stop.Please help me guys. iv.setOnTouchListener(this); mp1 = MediaPlaye
Solution 1:
public void onTouch(View v) {
if (mp.isPlaying()) {
mp.stop();
} else {
mp.start();
}
This will check when you Touch the ImageView if the Media Player is playing, if it is it will stop it, if not it will start it. With this you shouldn't need to use the switch case.
Be sure to set up your media player before this.
Post a Comment for "How To Play Sound By Ontouch And Stop When Fingures Up"