1

i want to loop the tasks that are performing on button click but it doesn't loop the handler thread if i have a toast in handler thread it is running on loop but task is not running in loop

my app is about to make a youtube video start from a specific time and end on a specific time and loop that clip over and over

                player.cueVideo("e_lWQPZKteE");
                //video is in cue so it load the video without playing it

            btDone.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
             for (int i=0; i<10 ; i++){
                    // this is method to start video and is working fine
                     skipToSecs = Integer.parseInt(seek_to_start.getText().toString());
                    endToSecs = Integer.parseInt(seek_to_end.getText().toString());
                    //showMessage("seek to  "+skipToSecs); // this is just a msg

                     player.seekToMillis(skipToSecs * 1000);//this is what makes video start
                    //from specific point
                    player.play();
                     vid_state = true;

                     //and this plays the video after it get that sepecific time stamp


                    //now lets make a method to stop video at a specific time stamp

                    formated_endToSecs =skipToSecs * 1000 + endToSecs* 1000 ;

                    //showMessage("the number is "+ formated_endToSecs);

                    new Handler(Looper.myLooper()).postDelayed(new Runnable() {
                        // thank you for this code https://stackoverflow.com/a/63430870
                        @Override
                        public void run() {
                            //do what you want
                            showMessage("video stopping on : "+ formated_endToSecs);
                            player.pause();
                        }
                    }, formated_endToSecs);
                    player.play();
                }
            });

}
IMRAN ALI
  • 11
  • 1

0 Answers0