VideoView控件

main.xml

android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">


android:layout_height="wrap_content">





VideoviewActivity.java
package com.videoview;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoviewActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);

setTitle("VideoView");

VideoView videoView = (VideoView) findViewById(R.id.videoView);

// 指定需要播放的视频的地址
videoView.setVideoURI(Uri.parse("android.resource://com.webabcd.view/" + R.raw.demo));
// videoView.setVideoPath();

// 设置播放器的控制条
videoView.setMediaController(new MediaController(this));
// 开始播放视频
videoView.start();
}
}

你可能感兴趣的:(android,移动开发,java)