I create small application which is media player. I have method where I have a song. I want to delay playing sound after I clicked a button. How I can do this delay. I want to click on the button and after 5 seconds music is playing. I am using: MediaPlayer.create to get song and mediaplayer.start() to start playing, but I don;t know how I can delay start playing my song.
I create small application which is media player. I have method where I have
Share
Use a Handler in your Activity to delay events such as starting the mediaplayer in your case:
In onClick of button, call
mRedrawHandler.sleep(5000);,startMusic()is a method where you are starting the mucsic playback.