2012-10-29 17 views
12

PLATFORM縦向きにプレイしていない:AndroidのSDKを使用してEclipseで開発 を16アンドロイドVideoViewは

問題: 私は480X800で画面全体を埋めることになっているVideoView要素(PORTRAITを持っていますオリエンテーション)、それは上手く再生されますが、肖像画に向きません。それはランドスケープモードに固執し、アスペクト比はそのようにゆがめられます。

  • をアンドロイド使用:screenOrientationは= "ポートレート" をマニフェスト
  • にアンドロイド使用:setRequestedOrientationを用いて容器の配向= "垂直" 及びVideoView自体
  • を私が試みているもの

    (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);私は、ディスプレイ

  • を回転させる480PXのx 800dpにVideoView幅と高さを設定しようとする代わりに、fill_parent
  • オートスイッチをオフfill_parent
  • の代わりに480dpx800dpするために、レイアウトの幅と高さを設定しようとしてsetContentView
  • を呼び出す直前

XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="480dp" 
    android:layout_height="800dp" 
    android:background="#000000" 
    android:orientation="vertical" > 

    <VideoView 
     android:id="@+id/opening_video" 
     android:layout_width="480dp" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentBottom="true" 
     android:layout_height="800dp" 
     android:orientation="vertical" /> 

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/transparent_button" 
     android:contentDescription="@string/back_button_desc" 
     android:background="@android:color/transparent" /> 

</RelativeLayout> 

CODE:

@Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
     setContentView(R.layout.activity_start_screen); 

     VideoView videoView = (VideoView) findViewById(R.id.opening_video); 

     Uri pathToVideo = Uri.parse("android.resource://com.example.consumerengage/" + R.raw.opening_tablet); 
     videoView.setVideoURI(pathToVideo); 
     videoView.setOnPreparedListener(new OnPreparedListener() { 
      @Override 
      public void onPrepared(MediaPlayer mp) { 
       mp.setLooping(true); 
      } 
     });   

     videoView.requestFocus(); 
     videoView.start(); 

     // boolean isPlaying = videoView.isPlaying() ; 

     // videoView.stopPlayback(); 
     // videoView.clearFocus(); 

     addListenerOnButton(); 

    } 

質問:私が試みた 何も成功しませんでした。 480x800のビデオを縦向きで再生するにはどうすればよいですか?

答えて

0

ここに私がやってしまったものです:

問題はOSのバージョンでした。それがICS(4.0)以上であれば、ビデオはその側で再生されるため、android.os.Build.VERSION.SDK_INTが14以上であることを検出すると、その側に構築されたビデオをロードして、正しい方法。

これは非常にばかげた回避策であり、私の質問に対する答えは決して得られませんでした。ビデオはそのようにはならないはずです。

0

これを試してみてください:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#000000"> 

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

    <ImageButton 
     android:id="@+id/imageButton1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/transparent_button" 
     android:contentDescription="@string/back_button_desc" 
     android:background="@android:color/transparent" /> 

</RelativeLayout> 

は、この情報がお役に立てば幸いです。また、マニフェストファイルも確認してください。

+0

XMLを上記の設定に変更すると、ビデオは水平方向に再生され、垂直方向には再生されません。 –

+0

@RickSあなたがしている間違いは、あなたのレイアウトとビデオビューに固定された高さと幅を定義することです。デフォルトのマッチ・ペアレントを使用し、マニフェスト・ファイルのアクティビティでandroid:screenOrientation = "portrait"と書いてください。 –

+0

android:screenOrientationをmanifeastファイル – AMD

2

あなたのビデオは480x800で、800x480ではないと確信していますか? 800x480は標準解像度です。電話でビデオを肖像画で録画しても、出力は800x480で、通常の再生をするにはビデオを90度回転させる必要があります。あなたが記述しているのは、480x800のvideoViewで800x480のビデオを再生しようとするとどうなるかということです。このような場合は、Windows Live MoviemakerやiMovieなどのビデオ編集ソフトウェアを使ってMac上で回転させることができます。

+0

+1であなたのアクティビティから削除してください。 –

+0

私たちは実際に、Final Cut Proのプロフェッショナル編集ソフトウェアでビデオをいくつかの解像度、コーデック、および方向でカットしました。奇妙なことは、1つのタブレットでうまくいくが、別のタブレットでは奇妙なことだった。 –

+0

@Rick Sどのタブレットが動作し、何がなかったのか –

1

あなたはpxを使用する必要がありますdpを使用している:

<VideoView 
    android:id="@+id/opening_video" 
    android:layout_width="480px" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentBottom="true" 
    android:layout_height="800px" 
    android:orientation="vertical" /> 

<ImageButton 
    android:id="@+id/imageButton1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/transparent_button" 
    android:contentDescription="@string/back_button_desc" 
    android:background="@android:color/transparent" /> 

か、あるいは(より良い) - ちょうどmatch_parent(またはfill_parent)を使用します。

<VideoView 
    android:id="@+id/opening_video" 
    android:layout_width="match_parent" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentBottom="true" 
    android:layout_height="match_parent" 
    android:orientation="vertical" /> 

<ImageButton 
    android:id="@+id/imageButton1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/transparent_button" 
    android:contentDescription="@string/back_button_desc" 
    android:background="@android:color/transparent" /> 

関連する問題