How to customize android VideoView Error Dialogue

时光怂恿深爱的人放手 提交于 2019-12-14 03:26:38

问题


In my application i want to stream video. In case if mobile can not play that video VideoView shows dilogue like this what i want if to customize this dialogue and insert two buttons one to download this video and one to try to play an Low Quality video. right now in onErrorLitener of VideoView i am showing dialogue to user but in this way with my dialogue VideoView own dialogue also show on screen which i don't want.

If i cant customize VideoView Error dialogue can i make it dont show on screen


回答1:


        AlertDialog.Builder builder=new Builder(YourActivityName.this);
        builder.setTitle("Video");
        builder.setMessage("Message you want to pass");
        builder.setPositiveButton("Download", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub

            }
        });
        builder.setNegativeButton("Play", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub

            }
        });
        builder.create();
        builder.show();

Just write code u wanna perform on download/play button click.




回答2:


I solved my problem @AkashG by putting your code in MediaPlay.setOnErrorListener()

AlertDialog.Builder builder=new Builder(YourActivityName.this);
        builder.setTitle("Video");
        builder.setMessage("Message you want to pass");
        builder.setPositiveButton("Download", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub

            }
        });
        builder.setNegativeButton("Play", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub

            }
        });
        builder.create();
        builder.show();


来源:https://stackoverflow.com/questions/11407108/how-to-customize-android-videoview-error-dialogue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!