Running a thread for some seconds

前端 未结 2 546
予麋鹿
予麋鹿 2021-01-16 07:37

I am using a media player instance to play a music file.I want to play the song for certain time then stop playing.I\'m using a thread with counter decrementing but some how

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-16 08:14

    this is something you can do.. Play with media player normally and at the same Time initialise a handler and call its postDelayed method with interval you want.. and inside it stop the MEdia player.. Something like this..

    new Handler().postDelayed(new Runnable(){
    
    //stop playing
    }, 400);
    

提交回复
热议问题