I want to play the video in the dialog box that appears when the image is clicked. The video does not play, and the application crashes. Here is my code:
image.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // custom dialog final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.introvid); dialog.show(); WindowManager.LayoutParams lp = new WindowManager.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.copyFrom(dialog.getWindow().getAttributes()); dialog.getWindow().setAttributes(lp); final VideoView videoview = (VideoView) findViewById(R.id.surface_view); Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.introvideo); videoview.setVideoURI(uri); videoview.start(); } });
my video is in the res / raw folder. His video is MP4.
android video dialog
Bhaijaan
source share