android使用VideoView设计的扫描全局.mp4和.3gp的视频播放器

在android的中提供了一个VideoView组件,用于播放视频文件,要想使用VideoView播放视频,首先要在布局文件中创建改组件,然后在activity中获取该组件,调用VideoView中的start方法来播放视频。首先通过扫描SD卡找到SD卡中MP4和3gp个是的视频文件,放在一个listView列表中,点击listview的单元格实现对当前视频文件的播放。

下面放上主要的代码

1、xml文件

list.xml文件为视频列表布局文件,主要包括一个listview显示视频列表和一个更新视频按钮

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
                  
    <TextView
        android:id="@+id/updatevedio"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:text="视频目录:"/>  
        
    <Button 
        android:id="@+id/updatevedioButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="更新视频"/>
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/updatevedio"
        android:id="@+id/lv">
    </ListView>  
       <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:textSize="20sp"
            android:text="C"/>              
</RelativeLayout>
list_sd.xml文件为listview单元格布局文件,只是显示了一个视频名称,显示缩略图以后再做。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <TextView
        android:layout_width="match_p
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值