在视频播放时在视频上显示图像按钮3-6秒。我尝试使用处理程序(延迟后方法),它第一次工作正常,但是当我们寻找视频时它不会显示所以我尝试使用该线程,但现在的问题是按钮onclick无效。
public void onPrepared(final MediaPlayer mediaPlayer){
if(position == 0){
mediaPlayer.start();
if (mediaPlayer.isPlaying()) {
}
}else{
videoView.seekTo((int) position);
videoView.start();
}
Thread t = new Thread() {
@Override
public void run() {
try {
while (!isInterrupted()) {
Thread.sleep(1000);
runOnUiThread(new Runnable() {
@Override
public void run() {
text.setText(String.valueOf(mediaPlayer.getCurrentPosition()));
String input = text.getText().toString();
inputValue = Integer.parseInt(input);
if(inputValue >= 3000 && inputValue <= 6000){
imagebutton.setVisibility(View.VISIBLE);
imagebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
stopPosition = videoView.getCurrentPosition(); //stopPosition is an int
Intent intent = new Intent(MainActivity.this, WebViewClass.class);
intent.putExtra("key", messsage);
intent.putExtra("intVariableName", stopPosition);
startActivity(intent);
}
});
}else{
imagebutton.setVisibility(View.INVISIBLE);
}
}
});
}
} catch (InterruptedException e) {
}
}
};
t.start();
}
});
它正在转移到WebViewClass.class但它崩溃了。