Reputation: 365
I need that VideoView get paused and Button on it get VISIBLE state when videoView.getCurrentPosition()==SPECIFIC_TIME (for example, 15000 milliseconds).
I've found some solutions using Timer or postDelayed but they're not ok for me because the video is paused when having income call or just having locked a smartphone, but Timer goes on and thus the Button can appear earlier than I need. Also I've found a solution with AsyncTask but can't check videoView.getCurrentPosition() in doInBackground.
How to solve it properly?
Upvotes: 1
Views: 678
Reputation: 209
Here is code for one solution:
videoView.requestFocus();
videoView.start();
while (videoView.getCurrentPosition() < (mSec-20)) { //mSec is the stop time
textView1.setText(getMilliToString(videoView.getCurrentPosition()));
// update time display
}
videoView.pause();
Another solution is access the MediaPlayer from the onPrepared method of the VideoView and then set the OnSeekCompleteListener, see code at: http://developer.samsung.com/technical-doc/view.do;jsessionid=0wJHWmGpLQFG7RYQLhP1D7VVLLyPl4lNyx1LmVDZMQ1QvRJK12WH!-2094516650?v=T000000092
Upvotes: 1