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();
			}
		});
	}
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

posted @ 2015-09-18 13:06  yxwkaifa  阅读(222)  评论(0编辑  收藏  举报