Вопрос

I have downloaded the Vitamio sample from here http://www.vitamio.org/en/Download/ and I'm successfully playing video on my Android Screen. But if I change my screen orientation, I'm unable to get FullScreen Mode.

Could anyone Help?

Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <io.vov.vitamio.widget.CenterLayout
        android:layout_width="match_parent"
        android:layout_height="300dp"
         android:layout_marginTop="40dp"

        android:orientation="vertical" >

        <io.vov.vitamio.widget.VideoView
            android:id="@+id/surface_view"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" />
    </io.vov.vitamio.widget.CenterLayout>


    <FrameLayout
                android:id="@+id/mainlayout"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginLeft="1dp"
                android:orientation="vertical" >

                <ImageButton
                    android:id="@+id/playbtn"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_marginLeft="1dp"

                    android:background="@drawable/play" />

                <ImageButton
                    android:id="@+id/pausebtn"
                    android:layout_width="30dp"
                   android:layout_marginLeft="1dp"

                    android:layout_height="30dp"
                    android:background="@drawable/pause" />
                 <SeekBar
                android:id="@+id/seekBar1"
                android:layout_width="270dp"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/mainlayout"
                android:layout_marginLeft="40dp"
                android:layout_marginRight="1dp" />

            </FrameLayout>





</LinearLayout>
Это было полезно?

Решение

try this

<io.vov.vitamio.widget.VideoView
    android:id="@+id/video"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" 
</io.vov.vitamio.widget.CenterLayout>

Другие советы

Use this method to stretch your videoview in onCreate() method of your activity

mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);

To handle onConfigurationChange();

use below code

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {

        mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
        Log.e("On Config Change", "LANDSCAPE");

    } else {
        mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_STRETCH, 0);
        Log.e("On Config Change", "PORTRAIT");
    }

}

also add this in your activity menifest file

android:configChanges="orientation|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top