Tôi đã thử một số ví dụ khác nhau nhưng tôi không thể hiển thị bất kỳ video nào. Tôi nghe thấy âm thanh nhưng không có video. Tôi nghĩ có lẽ tôi đã có một định dạng video không chính xác vì vậy tôi đã tải về một thương mại fiat ở định dạng 3gp và vẫn không có niềm vui. Tôi đang sử dụng Eclipse Java EE với sdk android và ứng dụng của tôi nhắm mục tiêu 1.5 sdk (Api Level 3) mà không cần google api. Ai đó có thể xin vui lòng gửi một liên kết đến một video được biết đến để chơi trong Android hoặc chỉ ra vấn đề của tôi với mã. Tôi đã thử tất cả tôi có thể nghĩ ra .. có/không có chuẩn bị .. bố trí khác nhau, vvvideo android, nghe âm thanh nhưng không có video
Dưới đây là onCreate của tôi trong hoạt động
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setContentView(R.layout.video_test);
SurfaceView v = (SurfaceView) findViewById(R.id.surface_video);
SurfaceHolder holder = v.getHolder();
// Set the transparency
//getWindow().setFormat(PixelFormat.UNKNOWN);
// Set a size for the video screen
//holder.addCallback(this);
holder.setFixedSize(400,300);
MediaPlayer mp = MediaPlayer.create(this, R.raw.fiat);
mp.setDisplay(holder);
//mp.setAudioStreamType(2);
try {
//mp.prepare();
mp.start();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cô là bố trí trong video_test.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"
>
<SurfaceView android:id="@+id/surface_video"
android:layout_width="250px"
android:layout_height="250px">
</SurfaceView>
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="10dip"
>
</LinearLayout>
</LinearLayout>
> Blockquote
Tôi đã có vấn đề này cũng như sử dụng một VideoView nhưng nếu tôi yêu cầu tập trung sau khi video bắt đầu sau đó nó hoạt động ok. – draksia