2011-12-06 17 views
0
vv = (VideoView)this.findViewById(R.id.videoView1); 
Uri uri = Uri.parse(url); 
vv.setVideoURI(uri); 
vv.start(); 

私はVideoViewを使ってURLビデオを再生しています。上記のような 。 しかし私はphone screenOrientationを変更しています。 すべての動画をリロードします。 プログラムをリロードアクションに改善するにはどうすればよいですか? ありがとうございました。VideoViewでビデオを再生していますが、再ロードしています

答えて

2

解決策1:(ほとんどの場合、これは動作します。)

があなたのVideoView xmlファイルを変更し、何かのように、

<?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/videoView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerInParent="true" /> 

</RelativeLayout> 

解決策2 ...

またはあなたの活動の姿勢の変化をハンドル、

AndroidManifest.xmlの動画のアクティビティタグ:

android:configChanges="orientation" 

だから、全体のラインは次のようになります。

<activity android:name="<Your video avtivityy>" android:configChanges="orientation" /> 

そして、この活動に次のメソッドを追加します

@Override 
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig); 
    // stuff for set video to proper position.. 
} 

をそして、私が起こるか知ってみましょう...

+0

方法2が答えです。ありがとうございました。 – brian

+0

しかし、私は何のために各ステップの仕事を知っていません。 – brian

+0

はい、onConfigurationChanged関数が意味することを知りたいと思います。 – brian

関連する問題