1

ビデオストリームをプレーヤーにロードするものがAsyncTaskあるので、実行中にロード画面を表示したいと思います。現在、私のonCreateコードは次のようになっています。

final View loadingView = getLayoutInflater().inflate(R.layout.video_loading, null);
final View playerView = getLayoutInflater().inflate(R.layout.player, null);
final VideoView videoView = (VideoView) playerView.findViewById(R.id.canvas);

Log.d(TAG, "Running video player for video " + videoId);

new VideoPlayingTask(this, videoView.getHolder()) {

    protected void onPreExecute() {
        setContentView(loadingView);
        super.onPreExecute(); // it creates or re-uses (resetting it before)
                            // MediaPlayer instance inside and sets display using setDisplay to the passed holder
    };

    protected void onPostExecute(FileInputStream dataSource) {

        setContentView(playerView);
        videoView.requestFocus();
        super.onPostExecute(dataSource); // it sets data source, 
                                        // prepares player and starts it
    };

 }.execute(videoId);

loadingViewが正しく表示され、コンテンツをに変更するplayerViewと画面が真っ暗になりますが、バックグラウンドで音が正しく再生されます。

ログのMediaPlayerから次の2つの警告が表示されます。

info/warning (1, 35)
info/warning (1, 44)

内部を使用ViewSwitherして呼び出しようとしましたが、に変更したときの動作は同様で、黒い画面でした。showNextViewonPostExecutevideoView

私は2つの内部レイアウトを電流の内側に配置し、それらの可視性を手動で切り替える方法を試しましたが、これも役に立ちませんでした。

このアクティビティでシングルを使用するとVideoView、完全に機能し、画像と音声の両方が表示されます。

video_loading.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"               
              android:gravity="center">
    <ProgressBar android:layout_width="@dimen/small_progress_side"
                 android:layout_height="@dimen/small_progress_side" />
    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginLeft="5dp"
              android:text="@string/caching_video" />
</LinearLayout>

player.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <VideoView android:id="@+id/canvas"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent" />
</LinearLayout> 

この質問は少し似ているように見えますが、私の場合、loadingView可視性をに切り替えることINVISIBLEはできません。

4

1 に答える 1

0

ビューを反転する代わりに使用したばかりProgressDialog.show()ですが、はるかに単純で、VideoView正しく処理されます。

于 2010-10-09T16:46:24.503 に答える