Android VideoView播放视频
来源:互联网 发布:双十一淘宝客服工资 编辑:程序博客网 时间:2024/06/11 17:48
Android 利用自带VideoView控件播放视频
Activity
public class Activity01 extends Activity{/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);final VideoView videoView = (VideoView) findViewById(R.id.VideoView01);Button PauseButton = (Button) this.findViewById(R.id.PauseButton);Button LoadButton = (Button) this.findViewById(R.id.LoadButton);Button PlayButton = (Button) this.findViewById(R.id.PlayButton);// loadLoadButton.setOnClickListener(new OnClickListener() {public void onClick(View arg0){//videoView.setVideoPath("/sdcard/test.mp4");videoView.setVideoPath("android.resource://com.homer/"+R.raw.china);videoView.setMediaController(new MediaController(Activity01.this));videoView.requestFocus();}});// playPlayButton.setOnClickListener(new OnClickListener() {public void onClick(View arg0){videoView.start();}});// pausePauseButton.setOnClickListener(new OnClickListener() {public void onClick(View arg0){videoView.pause();}});}}
main.xml
<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <VideoView android:id="@+id/VideoView01" android:layout_width="320px" android:layout_height="240px" /> <Button android:id="@+id/LoadButton" android:layout_width="80px" android:layout_height="wrap_content" android:layout_x="30px" android:layout_y="300px" android:text="装载" /> <Button android:id="@+id/PlayButton" android:layout_width="80px" android:layout_height="wrap_content" android:layout_x="120px" android:layout_y="300px" android:text="播放" /> <Button android:id="@+id/PauseButton" android:layout_width="80px" android:layout_height="wrap_content" android:layout_x="210px" android:layout_y="300px" android:text="暂停" /></AbsoluteLayout>
运行效果:
源码下载
- Android VideoView播放视频
- Android VideoView播放视频
- Android VideoView播放视频
- Android VideoView播放视频
- Android VideoView播放视频
- android videoview播放视频
- android---视频播放---VideoView
- Android视频播放---VideoView
- Android播放视频VideoView
- Android VideoView播放视频
- Android VideoView 播放视频
- [Android视频播放] VideoView
- Android视频播放: VideoView播放视频(三)
- (转)Android VideoView播放视频
- Android之VideoView播放视频
- Android播放视频(VideoView + MediaController)
- Android VideoView本地视频播放
- Android--使用VideoView播放视频
- 非线性信号滤波
- 实现内网通过外网域名访问NAT映射的内网服务器
- hadoop动态增加 datanode和tasktracker的方法
- Java 拼接 图片
- session的一些属性
- Android VideoView播放视频
- Eclipse开发PHP环境配置
- 2.20-2.21知识总结
- 对于SQL Server 2008开启sa用户名的方法
- PG源码分析
- ubuntu 創建LVM
- ubuntu下安装mysql与彻底卸载mysql方法
- 课上小结
- 用js实现猜数字小游戏