how to set video in full screen

10,224

Solution 1

Have you tried this:

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

in your class that contains mediaplayer code.

and in your xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_alignParentRight="true"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
             android:layout_alignParentBottom="true"
             android:layout_height="fill_parent">
    </VideoView>
 </RelativeLayout>

I hope this will help you.

Solution 2

No need of code to play video in full screen mode

Apply the following layout format over the xml containing the videoview it will for sure will play the video in full screen mode. as it is running mine :) Hope it helps

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent" >
   <VideoView android:id="@+id/myvideoview"
             android:layout_width="fill_parent"
             android:layout_alignParentRight="true"
             android:layout_alignParentLeft="true"
             android:layout_alignParentTop="true"
             android:layout_alignParentBottom="true"
             android:layout_height="fill_parent">
    </VideoView>
 </RelativeLayout>
Share:
10,224
RBJ
Author by

RBJ

Updated on June 04, 2022

Comments

  • RBJ
    RBJ almost 2 years

    hai how set video in full screen now i am attach my screen shot....

    alt text

    alt text

    <?xml version="1.0" encoding="utf-8"?>
     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="videothumb.videothumb"
      android:versionCode="1"
      android:versionName="1.0">
     <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".videothumb" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    
       <activity android:name="ViewVideo" android:label="@string/app_name"    
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
       <intent-filter><action android:name="android.intent.action.VIEW"></action>
       <category android:name="android.intent.category.DEFAULT"></category>
       </intent-filter>
       </activity>
    
       </application>
       <uses-sdk android:minSdkVersion="8" />
       <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS">
       </uses-permission>
       </manifest> 
    

    ViewVideo.java

    package videothumb.videothumb;
    
    
    import android.app.Activity;
    import android.content.Intent;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.view.SurfaceView;
    import android.view.View;
    import android.view.Window;
    import android.view.WindowManager;
    import android.view.View.OnClickListener;
    import android.widget.GridView;
    import android.widget.MediaController;
    import android.widget.VideoView;
    
    public class ViewVideo extends Activity {
      private String filename;
      private VideoView Video;
      @Override
      public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    
            setContentView(R.layout.main1);
            Video=(VideoView)findViewById(R.id.VideoView01);
            System.gc();
            Intent i = getIntent();
            Bundle extras = i.getExtras();
            filename = extras.getString("videofilename");
            Video.setVideoPath(filename);
            Video.setMediaController(new MediaController(this));
            Video.requestFocus();
            Video.start();
        }
    
      } `
    

    xml coding:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" 
     android:layout_width="fill_parent"
     android:layout_height="fill_parent">
    <VideoView 
    android:id="@+id/VideoView01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
    </VideoView>
    </LinearLayout>