登录
首页 » Android » Android VideoView的控件播放视频简单例子

Android VideoView的控件播放视频简单例子

于 2022-05-10 发布 文件大小:60.83 kB
0 178
下载积分: 2 下载次数: 1

代码说明:

Android VideoView的控件播放视频简单例子,这是最近在写一个Android项目时,需要用到视频播放的功能,索性直接使用了Android系统内自带的VideoView控件,对功能要求不太多,所以也可以满足应用,压缩包内包括了两个VideoView用法的例子:   public void onCreate(Bundle savedInstanceState)   {    super.onCreate(savedInstanceState);    setContentView(R.layout.main);    // 获取界面上VideoView组件    videoView = (VideoView) findViewById(R.id.video);    // 创建MediaController对象    mController = new MediaController(this);    File video = new File("/mnt/sdcard/test.mp4");    if(video.exists())    {    videoView.setVideoPath(video.getAbsolutePath());    // 设置videoView与mController建立关联    videoView.setMediaController(mController);    // 设置mController与videoView建立关联    mController.setMediaPlayer(videoView);    // 让VideoView获取焦点    videoView.requestFocus();    }   }

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • Android应用源码随手记安卓记账项目
    Android应用源码随手记安卓记账项目
    2015-03-09下载
    积分:1
  • android txt阅读器 实例源码
    android txt阅读器 实例源码
    2015-01-06下载
    积分:1
  • e4a单片机监测程序
    e4a单片机监测程序
    2019-11-13下载
    积分:1
  • Android 创建备忘录及闹铃提醒的例子
    Android 创建备忘录的例子,可自定义备忘录内容,自定义时间和自定义提醒闹钟的类型、铃声等。相关代码:   c.setTimeInMillis(System.currentTimeMillis());//设置当前时间   c.set(Calendar.HOUR_OF_DAY, hourOfDay);//设置小时   c.set(Calendar.MINUTE, minute);//设置分钟   c.set(Calendar.SECOND, 0);//设置秒   c.set(Calendar.MILLISECOND, 0);//设置毫秒   Intent intent=new Intent(Sample6_12_Activity.this,AlarmReceiver.class);//运行AlarmReceiver类   PendingIntent pi=PendingIntent.getBroadcast(//创建PendingIntent对象   Sample6_12_Activity.this, 0, intent, 0);   AlarmManager alarm=(AlarmManager)Sample6_12_Activity.this.getSystemService(ALARM_SERVICE);   alarm.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), pi);//设置闹钟提醒一次   alarm.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), 120000, pi);//每两分钟提醒一次   String tempHour=(hourOfDay+"").length()>1?hourOfDay+"":"0"+hourOfDay;   String tempMinute=(minute+"").length()>1?minute+"":"0"+minute;
    2022-02-05 23:21:02下载
    积分:1
  • Android中IntentService的特征
    service中1需要手动开启子线程2服务开启之后会一直运行,需要手动调用stopService();或者stopSelf(); intentService是一种异步(子线程)、自动停止的服务,这个例子测试IntentService的特征
    2022-05-20 04:17:23下载
    积分:1
  • 即时短信报警
    当你忘了什么事件等,生日...即时短信就在那里您可以轻松发送
    2022-02-25 07:25:18下载
    积分:1
  • Android文本显示与编辑功能代码演示
    本Android源码演示最简单的文本显示与编辑功能,如何在Android的用户界面中显示文本,如何编辑文本的显示属性,设置颜色、设置字体大小等,估计是最基础的Android编程小示例了,运行效果如截图所示。本代码主要是这样实现:   public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.main);    TextView textView = (TextView)findViewById(R.id.textview);    textView.setText(Html.fromHtml("这段文字的字体颜色为红色。"));   }
    2022-03-15 10:13:36下载
    积分:1
  • android 九宫格 解锁源码
    android 九宫格 解锁源码
    2014-07-14下载
    积分:1
  • Soruce_Code_Of_Secret_Of_Android_Application_Devel
    《Android应用开发揭秘》本书内容全面、循序渐进、深入浅出,实战性强,权威性毋庸置疑!全书一共分为5个部分:第一部分是准备篇,第二部分是基础篇,讲解了Android开发的相关知识,第三部分是实例篇,第四部分是高级篇,第五部分是扩展篇。(" Android Application Development Hood" of the book is comprehensive, step by step, easy to understand, combat and strong, authoritative doubt! The book is divided into a total of five parts: The first part is to prepare papers, articles based on the second part is to explain the Android development of knowledge, the third part is the instance of the article, the fourth part is the advanced part, Part V is to expand articles.)
    2020-06-25 22:40:02下载
    积分:1
  • zhejiang_android
    浙江大学Android开发的电子教程,是一门很好的Android入门教程,从Android的背景,到编程实例,深入简出的带你进入Android学习的天堂(An electronic document describes the development of Android, Android is a good introductory tutorial, from the Android' s background, to programming examples, in-depth simply take you out of heaven into the Android learning)
    2011-08-19 16:01:12下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载