0

私はマルチメディアアプリケーションをやっています。サーフェス ビューでビデオを実装するためにいくつかの異なる例を試しましたが、取得できません。音は聞こえますが、ビジュアルは表示されません。サーフェス ビューでビデオを取得する可能性はありますか。私のターゲット SDK は 2.2 API レベル 8 です。APK をモバイル デバイスにインストールしても、何も変わりません。私を案内してください。

4

1 に答える 1

0

ビデオの再生方法、ストリーミング方法、SD カードまたは /res フォルダーへのコピー方法がわかりませんが、ビデオを再生する方法は次のとおりです。ストリーミングするか、SD カードのフォルダーから再生するかを選択できます

ビデオ.java

import android.app.Activity;
import android.os.Bundle;
import android.widget.VideoView;

public class Movie extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        setContentView(R.layout.video_layout);
        VideoView video = (VideoView) findViewById(R.id.movie);

        //this is the place where you define where to get the video from (this can be from your sd or a stream)
        video.setVideoPath(
        "/sdcard/video/videofile.mp4"

        /*"rtsp://Youtube Stream*/
                );

        //after the video is loaded it will then start
        video.start();
    }
}

video_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" >
    <VideoView
        android:id="@+id/movie"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center">
    </VideoView>    
</FrameLayout>

これがあなたを助けることを願っています! SurfaceView にもいくつか問題がありましたが、この方法で問題は解決しました。

于 2011-01-29T10:02:14.233 に答える