欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

简易视频播放器

发布时间:2025/7/14 45 豆豆
生活随笔 收集整理的这篇文章主要介绍了 简易视频播放器 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

比较不错的源码:

倒计时的实现方案 - 类似限时抢购商品等
http://www.eoeandroid.com/thread-231924-1-1.html

android 仿IPHONE桌面图标抖动
http://www.eoeandroid.com/thread-231330-1-1.html

Android中如何使用ViewPager实现类似laucher左右拖动效果
http://www.eoeandroid.com/thread-231368-1-1.html

eoe积分商城:

http://www.eoeandroid.com/plugin.php?id=auction

-----------------帖子正文-------------------------

为了熟悉android视频方面的api,结合论坛里的资料,动手写了一个调用系统API的视频播放器,只能播放系统自带能解码的格式,界面比较简单,如下图:

代码主要有两个部分:

1.搜索手机中所有视频并显示

  主要通过以下代码实现:

cursor = getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, mediaColumns, null, null, null); if(cursor.moveToFirst()){ do{ VideoInfo info = new VideoInfo(); info.filePath = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA)); info.mimeType = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE)); info.title = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE)); Log.d("-name debug-", info.title+" "+info.filePath);//获取当前Video对应的Id,然后根据该ID获取其Thumb int id = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID)); BitmapFactory.Options options = new BitmapFactory.Options(); options.inDither = false; options.inPreferredConfig = Bitmap.Config.ARGB_8888; info.b = MediaStore.Video.Thumbnails.getThumbnail(getContentResolver(), id, Images.Thumbnails.MICRO_KIND, options); //然后将其加入到videoList videoList.add(info); }while(cursor.moveToNext()); }

2.播放视频

通过videoview实现

protected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.player);viv=(VideoView)findViewById(R.id.videoView);mController=new MediaController(this);viv.setMediaController(mController);String videopath=getIntent().getStringExtra("path");if (videopath!=null) {viv.setVideoPath(videopath);}viv.requestFocus();viv.start();}


源码下载

 

转载于:https://www.cnblogs.com/vus520/archive/2012/11/26/2788730.html

总结

以上是生活随笔为你收集整理的简易视频播放器的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。