我正在使用 Videoview 使用 android 模拟器从本地机器播放 mp4 文件。我听到了声音,但屏幕是空白的,看不到视频。安卓 SDK 2.0.1
有谁知道这里缺少什么:
package com.hello;
import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class HelloAndroid extends Activity {
VideoView vv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vv = (VideoView) findViewById(R.id.VideoView01);
MediaController nc = new MediaController(this);
vv.setMediaController(nc);
vv.setVideoPath("/sdcard/yu.mp4");
vv.requestFocus();
vv.start();
}
public void onPause() {
vv.stopPlayback();
}
}
主.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<VideoView
android:id="@+id/VideoView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></VideoView>
</LinearLayout>