android利用videoView播放视频(已封装)

//android播放视频,使用方法:在androidManifest.xml中添加activity,
// <activity android:name=".PlayVideo"
//                  android:label="@string/app_name">
//
//        </activity>
//注意资源路径
//调用时:
//Intent intent = new Intent(MainActivity.this, PlayVideo.class);  //从mainActivity跳转到playvideo中
//this.startActivity(intent); 
//白白原创
package com.homer;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;



public class PlayVideo extends Activity
{
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		final VideoView videoView = (VideoView) findViewById(R.id.VideoView01);
		videoView.setVideoPath("android.resource://com.homer/"+R.raw.test);
		videoView.setMediaController(new MediaController(PlayVideo.this));
		videoView.requestFocus();
		videoView.start();
		
		Button stopButton = (Button) this.findViewById(R.id.stopButton);
		stopButton.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0)
			{
				videoView.stopPlayback();
			}
		});
	}
}

android利用videoView播放视频(已封装),布布扣,bubuko.com

android利用videoView播放视频(已封装)

上一篇:ios开发:UINavigationController反方向滑动push


下一篇:安卓实训第四天--基于HttpClient来完成数据在服务器和设备间的交互。