嗨,我需要显示 sd 卡中的视频。我将视频保存在 SD 卡中并尝试使用以下代码。但是视频没有显示....请帮助我哪里出错了....
我的代码:
package com.videoapp;
import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class NewvideoappActivity extends Activity
{
private VideoView vView;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vView = (VideoView)findViewById(R.id.myvideoview);
vView.requestFocus();
vView.setVideoPath("/sdcard/watch.3gp");
vView.setMediaController(new MediaController(this));
vView.start();
}
}
主要的.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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<VideoView
android:id="@+id/myvideoview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
日志猫:
提前致谢...