码迷,mamicode.com
首页 > 移动开发 > 详细

android采用videoView播放视频(包装)

时间:2015-09-18 13:52:26      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

//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播放视频(包装)

标签:

原文地址:http://www.cnblogs.com/yxwkf/p/4818918.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!