我想以动态时间间隔显示照片和视频的数量。我的条件是
1)以动态间隔显示照片 2)当视频在那里时,播放视频并停止任务, 3)播放视频简历线程或我们使用的任何内容后。
我尝试使用Thread,但视频出现问题,并且线程表现出意外。有没有更好的解决方案或建议,
以下是我在MainActivity.class中的代码
timer = new Thread() {
public void run() {
try {
for (int z = 0; z < userStories.size(); z++) {
Log.e("File Name--->", userStories.get(z).getFileName());
Log.e("File TYPEEEE--->", userStories.get(z).getType());
if (userStories.get(z).getType().equalsIgnoreCase("photo")) {
Log.e("SLEEEEEPppp-->", "SO GAYA THREAD");
sleep(Long.parseLong(userStories.get(z).getDisplayTime()) * 1000);
final int finalZ = z;
runOnUiThread(new Runnable() {
@Override
public void run() {
image.setVisibility(View.VISIBLE);
video_view.setVisibility(View.GONE);
Glide.with(getApplicationContext())
.load(userStories.get(finalZ).getFileName())
.into(image);
}
});
} else if (userStories.get(z).getType().equalsIgnoreCase("video")) {
/*synchronized (this) {
Log.e("Waitttttt-->", "Wait kar riya he...");
wait();
}*/
final int finalZ2 = z;
runOnUiThread(new Runnable() {
@Override
public void run() {
image.setVisibility(View.GONE);
video_view.setVisibility(View.VISIBLE);
String VideoURL = userStories.get(finalZ2).getFileName();
uri = Uri.parse(VideoURL);
if (!TextUtils.isEmpty(VideoURL)) {
video_view.setVideoURI(uri);
video_view.requestFocus();
video_view.start();
video_view.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
pauseWork = false;
}
});
video_view.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
Log.e("VIDEooooooo--->", "Completeeeee");
Log.e("Thread Notifyyyy--->", "Hooo Gayaaaaaa");
timer.interrupt();
}
});
}
}
});
/*synchronized (timer) {
Log.e("WAITTTTTT-->", "WAIT KAR RIYA HE");
timer.wait();
}*/
}
final int finalZ1 = z;
runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < userStories.size(); i++) {
if (i == finalZ1) {
dots[i].setImageDrawable(getResources().getDrawable(R.drawable.selecteditem_dot));
} else {
dots[i].setImageDrawable(getResources().getDrawable(R.drawable.nonselecteditem_dot));
}
}
}
});
}
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
runOnUiThread(new Runnable() {
@Override
public void run() {
}
});
}
}
};
timer.start();
提前感谢您的帮助
答案 0 :(得分:1)
您可以使用处理程序,尝试下面的代码。首先,你必须调用CallNext()方法。
SCRIPT5007: Unable to get property 'meteorInstall' of undefined or null reference es5-shim.js (17,1)