1

我有一个可以播放的介绍视频,不同大小的视频放置在 drawable-[h,m,l]dpi 文件夹中。我将其设置为始终以纵向模式播放。

布局

 <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_height="fill_parent"
    android:layout_gravity="center"
    android:orientation="vertical"/>
 </RelativeLayout>

显现

<activity android:name=".IntroActivity"
                  android:configChanges="keyboardHidden|orientation|screenSize"
                  android:screenOrientation="portrait"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

但是,该视频在我的 4.0.4 平板电脑上以横向播放,但在我的 2.2.1 手机上可以使用。

介绍活动

protected void onStart()
{
    try
    {   
        setContentView(R.layout.intro);
        videoHolder = (VideoView)findViewById(R.id.myvideoview);

        Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.intro);
        videoHolder.setVideoURI(video);

        videoHolder.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
        {
            public void onCompletion(MediaPlayer mp)
            {
                if (touched == false)
                {
                    startActivity(new Intent("com.eg.flupaniclite.menu"));
                }

            }
        });
        videoHolder.setOnErrorListener(new MediaPlayer.OnErrorListener()
        {
            @Override
            public boolean onError(MediaPlayer mp, int what, int extra)
            {
                if (touched == false)
                {
                    startActivity(new Intent("com.eg.flupaniclite.menu"));
                }
                return false;
            }
        });

        videoHolder.start();

    }
    catch (Exception e)
    {
        if (touched == false)
        {
            startActivity(new Intent("com.eg.flupaniclite.menu"));
        }
    }

    super.onStart();
}
4

0 回答 0