Retrieving Media from a Content Resolver
来源:互联网 发布:淘宝账号被永久封号 编辑:程序博客网 时间:2024/05/21 19:24
在设备中查找音乐:
ContentResolver contentResolver= getContentResolver();
Uri uri= android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
Cursor cursor= contentResolver.query(uri,null, null, null, null);
if(cursor ==null) {
// query failed, handle error.
} else if(!cursor.moveToFirst()){
// no media on the device
} else {
int titleColumn= cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.TITLE);
int idColumn= cursor.getColumnIndex(android.provider.MediaStore.Audio.Media._ID);
do{
long thisId= cursor.getLong(idColumn);
String thisTitle= cursor.getString(titleColumn);
// ...process entry...
}while (cursor.moveToNext());
}
在MediaPlayer中使用它:
long id = /* retrieve it from somewhere */;Uri contentUri = ContentUris.withAppendedId( android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id);mMediaPlayer = new MediaPlayer();mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);mMediaPlayer.setDataSource(getApplicationContext(), contentUri);// ...prepare and start...
- Retrieving Media from a Content Resolver
- content resolver
- ContentProvider 与Content Resolver
- Content Provider Resolver
- Content provide & content resolver comments
- Retrieving CD Information from a remote Freedb database
- Retrieving HTTP content in .NET
- Loading HTML content from a Stream
- Writing CAML Queries For Retrieving List Items from a SharePoint List1
- 从数据库表中检索所有行20.5.4.Retrieving All Rows from a Database Table
- content://media/external/fs_id
- Retrieving HTTP content in .NET - POSTing data
- Retrieving RSS feed with tag <content:encoded>
- Retrieving a List of Contacts
- Retrieving Details for a Contact
- Retrieving a List of Contacts
- Retrieving Details for a Contact
- Retrieving OLE Object (Image) from Access
- U-boot的环境变量: bootcmd 和bootargs
- 试题二:最接近神的人(sophist/pas/c/cpp) (逆序对)
- 常见时区缩写
- 修改hosts文件无效解决办法
- VS 2010编译Gh0st 3.6
- Retrieving Media from a Content Resolver
- 借船过河:一个据说能看穿你的人性和欲望的心理测试
- window.open居中显示,模式窗口
- 如何使用EnumSet实现基于bit field的enum set?
- tyvj-1144 股票 DP
- Android系列教程之七:EditText使用详解-包含很多教程上看不到的功能演示
- 通过帧标签获取对应的帧
- 不要在功能上竞争
- 移植ads7846驱动到tiny6410(tiny6410)