-1
編輯: 我喜歡這個在我的線程內幫助我的堆棧溢出朋友在android中的對話框內顯示視頻視圖但凍結我的應用程序幫助我非常感謝提前修復無法在未調用Looper.prepare()的線程中創建處理程序
這是從Thread我的活動:
Auto_Bucket_Tests_Thread = new Thread(new Runnable()
{
@SuppressWarnings("deprecation")
@Override
public void run() {
while(Test_Completed==false)
{
if(Login.Bucket_Status==true && Video_Status==false)
{
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Bucket_Open_Error();
}
});
}
else if(Login.Bucket_Status==false && Video_Status==true)
{
videodialog.cancel();
}
}
Auto_Bucket_Tests_Thread.stop();
}
});
}
protected void Bucket_Open_Error() {
videodialog = new Dialog(this);
videodialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
videodialog.setContentView(R.layout.videodialog);
videodialog.show();
WindowManager.LayoutParams layout_params =new WindowManager.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
layout_params.copyFrom(videodialog.getWindow().getAttributes());
layout_params.dimAmount=0;
videodialog.getWindow().setAttributes(layout_params);
final VideoView video = (VideoView)videodialog.findViewById(R.id.videoView_dialog);
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.doorsclosing);
video.setVideoURI(uri);
video.start();
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
Video_Status=true;
video.start();
//app_message.show();
}
});
對不起遲到重播老兄我沒有得到你可以請再告訴我如何做到這一點,因爲我是新來的這個@ EE66 – dEePU
老兄我確實喜歡你說的,但它凍結應用程序,請幫我貼我的以上代碼@ EE66 – dEePU
將If改爲If。你已經打開了多個視頻。這就是爲什麼你堅持你的UI線程 – EE66