1. Check out our companion app, Forums for Android! Download from Google Play

how to play video in Full Screen??!

Discussion in 'Application Development' started by wounded, Nov 5, 2012.

  1. wounded

    wounded Active Member
    Thread Starter
    15

    Jul 27, 2012
    35
    0
    15
    Hi all,

    can someone help me how t play video in full-Screen android.
    my video play but not in fullScreen.

    [​IMG]

    here is my code;
    MainActivity.java
    --------------------

    public
    class MainActivity extends Activity {


    @Override
    publicvoid onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    VideoView vd = (VideoView) findViewById(R.id.VideoView);
    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(vd);
    vd.setMediaController(mediaController);
    vd.setKeepScreenOn(true);
    vd.setVideoPath("android.resource://com.video.pideo/raw/"+R.raw.number);
    vd.start();
    vd.requestFocus();


    }
    }

    Activity_main.xml
    --------------------
    <?xmlversion="1.0"encoding="utf-8"?>

    <



    LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"


    android:layout_width


    ="fill_parent"

    android:layout_height


    ="fill_parent"

    >



    <


    VideoView

    android:id="@+id/VideoView"
    android:layout_width="fill_parent"
    android:layout_height="666dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true">
    </


    VideoView>
    </LinearLayout>


    ihope toget a reply
    thnks in advance​
     

    Advertisement

  2. jonbonazza

    jonbonazza Well-Known Member
    163

    Jul 13, 2010
    1,934
    459
    163
    Male
    your android:layout_height attribute for your VideoView is set to 666dip. For fullscreen, you should set it to fill_parent.
     
  3. wounded

    wounded Active Member
    Thread Starter
    15

    Jul 27, 2012
    35
    0
    15

    Welcome jonbonazza,

    it doesnt work

    as you saw Previous picture,,my actual video is in the black color and it leave a gap or blank space between video and buttons(play/stop...) who can i remove this space?

    thnkx
     
  4. jonbonazza

    jonbonazza Well-Known Member
    163

    Jul 13, 2010
    1,934
    459
    163
    Male
    Did you try this?

    Code (Text):
    1.  
    2. Activity_main.xml
    3. --------------------
    4. <?xmlversion="1.0"encoding="utf-8"?>
    5. <LinearLayout
    6. xmlns:android="http://schemas.android.com/apk/res/android"
    7. android:layout_width="fill_parent"
    8. android:layout_height="fill_parent"
    9. android:orientation="vertical"
    10. >
    11. <VideoView
    12. android:id="@+id/VideoView"
    13. android:layout_width="fill_parent"
    14. android:layout_height="fill_parent"
    15. android:layout_alignParentBottom="true"
    16. android:layout_alignParentLeft="true"
    17. android:layout_alignParentRight="true"
    18. android:layout_alignParentTop="true">
    19. </VideoView>
    20. </LinearLayout>
    21.  
     
  5. wounded

    wounded Active Member
    Thread Starter
    15

    Jul 27, 2012
    35
    0
    15

    i got this , still the same

    [​IMG]
     
  6. jonbonazza

    jonbonazza Well-Known Member
    163

    Jul 13, 2010
    1,934
    459
    163
    Male
    Hmm thinking about it, VideoView is probably coded to retain a certain aspect ratio, so it likely won't go fullscreen in portrait mode. Does it work as intended in landscape mode?

    EDIT: Moved to main Android App Dev forums.
     
  7. mrichards957

    mrichards957 Member
    26

    Nov 15, 2012
    6
    1
    26
    Male
    Software Developer
    Littleton, CO
    I did a project a while back where I had to be able to control the aspect ratio of a VideoView control. What I ended up doing was create a class that extends VideoView and then override the "onMeasure" method to calculate the width and height I wanted and call "setMeasuredDimension" with those values. Otherwise I think jonbonazza is right, the VideoView will try to keep a set aspect ratio.

    To set the video to full screen, I think you need to use something like this:

    [HIGH]
    public class MyVideoView extends VideoView {

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int containerWidth = MeasureSpec.getSize(widthMeasureSpec);
    int containerHeight = MeasureSpec.getSize(heightMeasureSpec);
    setMeasuredDimension(containerWidth, containerHeight);
    }

    }
    [/HIGH]
     
    jonbonazza likes this.
  8. jonbonazza

    jonbonazza Well-Known Member
    163

    Jul 13, 2010
    1,934
    459
    163
    Male
    I agree with mrichards957. I did some more searching and this is the only conclusion I could seem to come up with, albeit not exactly convenient.
     
  9. wounded

    wounded Active Member
    Thread Starter
    15

    Jul 27, 2012
    35
    0
    15
    it doesnt work with me..
    i will try to use webview to play .swf files that contains video
    so if you any idea
    thnks to all for ur reply
     

Share This Page

Loading...