请看代码~~
红色字体总是提示错误,我真不知道怎么改了~~ 文件raw内的video1.3gp,只是想程序开始播放这个而已,我该怎么做~~
public class AdActivity extends Activity {
private VideoView v;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
v = (VideoView) findViewById(R.id.videoView1);
Uri uri=Uri.parse
(
"android.resource://com.ad/"+ R.raw.video1
);
v.setVideoURI(uri);
v.requestFocus();
v.start();
v.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer arg0)
{
/*略*/ }
});
}
}
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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/videoView1">
</VideoView>
</LinearLayout>
红色字体总是提示错误,我真不知道怎么改了~~ 文件raw内的video1.3gp,只是想程序开始播放这个而已,我该怎么做~~
public class AdActivity extends Activity {
private VideoView v;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
v = (VideoView) findViewById(R.id.videoView1);
Uri uri=Uri.parse
(
"android.resource://com.ad/"+ R.raw.video1
);
v.setVideoURI(uri);
v.requestFocus();
v.start();
v.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer arg0)
{
/*略*/ }
});
}
}
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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/videoView1">
</VideoView>
</LinearLayout>
你确定你的命名没有问题?
http://topic.csdn.net/u/20110917/11/690b33d5-a427-40b1-af22-582ffa0c5ea9.html?032997219237895203