b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

视频播放器java版 Android 安卓RecyclerView显示本地视频并播放(3)

电脑杂谈  发布时间:2017-12-21 05:01:03  来源:网络整理

?? ?? ?? ?? super.onCreate(savedInstanceState);

?? ?? ?? ?? setContentView(R.layout.activity_main);

?? ?? ?? ?? rv = (RecyclerView) findViewById(R.id.rv_local);

// ?? ?? ?? ??设置布局管理器

?? ?? ?? ?? LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);

?? ?? ?? ?? rv.setLayoutManager(manager);

?? ?? ?? ?? mDatas = new ArrayList<>();

// ?? ?? ?? ??设置适配器对象

?? ?? ?? ?? adapter = new LocalVideoAdapter(this, mDatas);

?? ?? ?? ?? rv.setAdapter(adapter);

// ?? ?? ?? ??加载sd卡当中的视频,即真实的数据源

?? ?? ?? ?? loadData();

?? ?? }

?? ?? private void loadData() {

?? ?? ?? ?? List<LocalVideoInfo> list = new ArrayList<>();

// ?? ?? ?? ??1.获取ContentResolver对象

?? ?? ?? ?? ContentResolver resolver = getContentResolver();

// ?? ?? ?? ??2.获取Uri地址

?? ?? ?? ?? Uri videoUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;

// ?? ?? ?? ??3.开始查询系统视频

?? ?? ?? ?? Cursor cursor = resolver.query(videoUri, null, null, null, MediaStore.Video.Media.DISPLAY_NAME);

// ?? ?? ??4.移动cursor指针

视频播放器java版_stream6视频_手机视频播放器java

?? ?? ?? ?? while (cursor.moveToNext()) {

?? ?? ?? ?? ?? ?? String name = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DISPLAY_NAME));

?? ?? ?? ?? ?? ?? String path = cursor.getString(cursor.getColumnIndex(MediaStore.Video.Media.DATA));

?? ?? ?? ?? ?? ?? long duration = cursor.getLong(cursor.getColumnIndex(MediaStore.Video.Media.DURATION));

?? ?? ?? ?? ?? ?? long size = cursor.getLong(cursor.getColumnIndex(MediaStore.Video.Media.SIZE));

?? ?? ?? ?? ?? ?? LocalVideoInfo info = new LocalVideoInfo(name,path,duration,size);


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/bofangqi/article-54866-3.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...