0

i working videoview. i wrote code witch can play video from url with asynctask.at the moment everythink is ok but i have another problem.when i run my app videoview is not full screen.

[i have like this resulit 1

this is a my source

public class Layout1 extends Fragment  {




VideoView video;
MediaController media;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


}

@SuppressWarnings("deprecation")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {


    View view = inflater.inflate(R.layout.fragment_layout1, null);


    video = (VideoView) view.findViewById(R.id.video_view);


    new BackgroundAsyncTask()
    .execute(Global.yutubeDownloadUrl);











    return view;
}

public class BackgroundAsyncTask extends AsyncTask<String, Uri, Void> {
    Integer track = 0;
    ProgressDialog dialog;

    protected void onPreExecute() {
        dialog = new ProgressDialog(getActivity());
        dialog.setMessage("Loading, Please Wait...");
        dialog.setCancelable(true);
        dialog.show();
    }

    protected void onProgressUpdate(final Uri... uri) {

        try {

            media=new MediaController(getActivity());
            video.setMediaController(media);
            media.setVisibility(View.GONE);
            media.setPrevNextListeners(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // next button clicked

                }
            }, new View.OnClickListener() {
                @Override
                public void onClick(View v) {


                }
            });
            media.show();

            video.setVideoURI(uri[0]);
            video.requestFocus();
            video.setOnPreparedListener(new OnPreparedListener() {

                public void onPrepared(MediaPlayer arg0) {
                    video.start();
                    dialog.dismiss();
                }
            });


        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalStateException e) {
            e.printStackTrace();
        } catch (SecurityException e) {

            e.printStackTrace();
        }


    }

    @Override
    protected Void doInBackground(String... params) {
        try {
            Uri uri = Uri.parse(params[0]);

            publishProgress(uri);
        } catch (Exception e) {
            e.printStackTrace();

        }

        return null;
    }


}

and xml code

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<VideoView
    android:id="@+id/video_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

what am i doing wrong? if anyone knows solution please help me

user3804530
  • 95
  • 1
  • 1
  • 7

1 Answers1

0

The easy way is to change your activity theme to

 @android:style/Theme.Holo.NoActionBar.Fullscreen 

or

@android:style/Theme.Black.NoTitleBar.Fullscreen

(as long as it has fullscreen in the name it's fine). if you really need the videoview to be in a fragment there might be some problems, but as i see your code you can use an activity instead of that fragment and set the theme for that activity.

By the way... you don't need to use an async.