本文整理汇总了Java中android.provider.MediaStore.Audio类的典型用法代码示例。如果您正苦于以下问题:Java Audio类的具体用法?Java Audio怎么用?Java Audio使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Audio类属于android.provider.MediaStore包,在下文中一共展示了Audio类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openAudioThumbnailCleared
import android.provider.MediaStore.Audio; //导入依赖的package包/类
protected ParcelFileDescriptor openAudioThumbnailCleared(long id, CancellationSignal signal)
throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
Cursor cursor = null;
try {
cursor = resolver.query(Audio.Albums.EXTERNAL_CONTENT_URI,
AudioThumbnailQuery.PROJECTION, Audio.Albums._ID + "=" + id,
null, null);
if (cursor.moveToFirst()) {
final String data = cursor.getString(AudioThumbnailQuery._DATA);
return ParcelFileDescriptor.open(
new File(data), ParcelFileDescriptor.MODE_READ_ONLY);
}
} finally {
IoUtils.closeQuietly(cursor);
}
return null;
}
示例2: constructPartFromUri
import android.provider.MediaStore.Audio; //导入依赖的package包/类
public static PduPart constructPartFromUri(Context context, Uri uri) throws IOException, MediaTooLargeException {
PduPart part = new PduPart();
assertMediaSize(context, uri);
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri, new String[]{Audio.Media.MIME_TYPE}, null, null, null);
if (cursor != null && cursor.moveToFirst())
part.setContentType(cursor.getString(0).getBytes());
else
throw new IOException("Unable to query content type.");
} finally {
if (cursor != null)
cursor.close();
}
part.setDataUri(uri);
part.setContentId((System.currentTimeMillis()+"").getBytes());
part.setName(("Audio" + System.currentTimeMillis()).getBytes());
return part;
}
示例3: getQueryCursor
import android.provider.MediaStore.Audio; //导入依赖的package包/类
private Cursor getQueryCursor(AsyncQueryHandler async, String filter) {
if (filter == null) {
filter = "";
}
String[] ccols = new String[] {
BaseColumns._ID, Audio.Media.MIME_TYPE, Audio.Artists.ARTIST, Audio.Albums.ALBUM,
Audio.Media.TITLE, "data1", "data2"
};
Uri search = Uri.parse("content://media/external/audio/search/fancy/" + Uri.encode(filter));
Cursor ret = null;
if (async != null) {
async.startQuery(0, null, search, ccols, null, null, null);
} else {
ret = MusicUtils.query(this, search, ccols, null, null, null);
}
return ret;
}
示例4: onCreateContextMenu
import android.provider.MediaStore.Audio; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
menu.setHeaderTitle(R.string.image_edit_artists);
getMenuInflater().inflate(R.menu.music_context_artistimage, menu);
} else if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
menu.setHeaderTitle(R.string.image_edit_albums);
getMenuInflater().inflate(R.menu.music_context_albumimage, menu);
} else if (Playlists.CONTENT_TYPE.equals(mimeType)) {
menu.setHeaderTitle(R.string.image_edit_playlist);
getMenuInflater().inflate(R.menu.music_context_playlist_genreimage, menu);
}
else{
menu.setHeaderTitle(R.string.image_edit_genre);
getMenuInflater().inflate(R.menu.music_context_playlist_genreimage, menu);
}
}
示例5: onSearchWeb
import android.provider.MediaStore.Audio; //导入依赖的package包/类
public void onSearchWeb(){
String query = "";
if (Audio.Artists.CONTENT_TYPE.equals(mimeType)) {
query = getArtist();
} else if (Audio.Albums.CONTENT_TYPE.equals(mimeType)) {
query = getAlbum() + " " + getArtist();
} else if (Playlists.CONTENT_TYPE.equals(mimeType)) {
query = bundle.getString(PLAYLIST_NAME);
}
else{
Long id = bundle.getLong(BaseColumns._ID);
query = MusicUtils.parseGenreName(this, MusicUtils.getGenreName(this, id, true));
}
final Intent googleSearch = new Intent(Intent.ACTION_WEB_SEARCH);
googleSearch.putExtra(SearchManager.QUERY, query);
startActivity(googleSearch);
}
示例6: makeAutoShuffleList
import android.provider.MediaStore.Audio; //导入依赖的package包/类
private boolean makeAutoShuffleList() {
ContentResolver res = getContentResolver();
Cursor c = null;
try {
c = res.query(Audio.Media.EXTERNAL_CONTENT_URI, new String[] {
BaseColumns._ID
}, AudioColumns.IS_MUSIC + "=1", null, null);
if (c == null || c.getCount() == 0) {
return false;
}
int len = c.getCount();
long[] list = new long[len];
for (int i = 0; i < len; i++) {
c.moveToNext();
list[i] = c.getLong(0);
}
mAutoShuffleList = list;
return true;
} catch (RuntimeException ex) {
} finally {
if (c != null) {
c.close();
}
}
return false;
}
示例7: onCreateLoader
import android.provider.MediaStore.Audio; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String[] projection = new String[] {
BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
};
StringBuilder selection = new StringBuilder();
Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
uri = Audio.Media.EXTERNAL_CONTENT_URI;
long[] mNowPlaying = MusicUtils.getQueue();
if (mNowPlaying.length == 0)
return null;
selection = new StringBuilder();
selection.append(BaseColumns._ID + " IN (");
if (mNowPlaying == null || mNowPlaying.length <= 0)
return null;
for (long queue_id : mNowPlaying) {
selection.append(queue_id + ",");
}
selection.deleteCharAt(selection.length() - 1);
selection.append(")");
return new AddIdCursorLoader(getActivity(), uri, projection, selection.toString(), null,
sortOrder);
}
示例8: reloadQueueCursor
import android.provider.MediaStore.Audio; //导入依赖的package包/类
/**
* Reload the queue after we remove a track
*/
private void reloadQueueCursor() {
String[] projection = new String[] {
BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
};
StringBuilder selection = new StringBuilder();
Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
uri = Audio.Media.EXTERNAL_CONTENT_URI;
long[] mNowPlaying = MusicUtils.getQueue();
if (mNowPlaying.length == 0)
return;
selection = new StringBuilder();
selection.append(BaseColumns._ID + " IN (");
if (mNowPlaying == null || mNowPlaying.length <= 0)
return;
for (long queue_id : mNowPlaying) {
selection.append(queue_id + ",");
}
selection.deleteCharAt(selection.length() - 1);
selection.append(")");
mCursor = MusicUtils.query(getActivity(), uri, projection, selection.toString(), null,
sortOrder);
mQuickQueueAdapter.changeCursor(mCursor);
}
示例9: setupFragmentData
import android.provider.MediaStore.Audio; //导入依赖的package包/类
@Override
public void setupFragmentData() {
mAdapter = new AlbumListAdapter(getActivity(), R.layout.music_listview_items, null,
new String[] {}, new int[] {}, 0);
mProjection = new String[] {
BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
};
StringBuilder where = new StringBuilder();
where.append(AudioColumns.IS_MUSIC + "=1")
.append(" AND " + MediaColumns.TITLE + " != ''");
long albumId = getArguments().getLong(BaseColumns._ID);
where.append(" AND " + AudioColumns.ALBUM_ID + "=" + albumId);
mWhere = where.toString();
mSortOrder = Audio.Media.TRACK + ", " + Audio.Media.DEFAULT_SORT_ORDER;
mUri = Audio.Media.EXTERNAL_CONTENT_URI;
mFragmentGroupId = 89;
mType = TYPE_ALBUM;
mTitleColumn = MediaColumns.TITLE;
}
示例10: setupFragmentData
import android.provider.MediaStore.Audio; //导入依赖的package包/类
public void setupFragmentData(){
mAdapter = new RecentlyAddedAdapter(getActivity(), R.layout.music_listview_items,
null, new String[] {}, new int[] {}, 0);
mProjection = new String[] {
BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
};
StringBuilder where = new StringBuilder();
int X = MusicUtils.getIntPref(getActivity(), NUMWEEKS, 5) * 3600 * 24 * 7;
where.append(MediaColumns.TITLE + " != ''");
where.append(" AND " + AudioColumns.IS_MUSIC + "=1");
where.append(" AND " + MediaColumns.DATE_ADDED + ">"
+ (System.currentTimeMillis() / 1000 - X));
mWhere = where.toString();
mSortOrder = MediaColumns.DATE_ADDED + " DESC";
mUri = Audio.Media.EXTERNAL_CONTENT_URI;
mTitleColumn = MediaColumns.TITLE;
}
示例11: setupFragmentData
import android.provider.MediaStore.Audio; //导入依赖的package包/类
@Override
public void setupFragmentData(){
mAdapter = new ArtistListAdapter(getActivity(), R.layout.music_listview_items, null,
new String[] {}, new int[] {}, 0);
mProjection = new String[] {
BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
};
StringBuilder where = new StringBuilder();
where.append(AudioColumns.IS_MUSIC + "=1")
.append(" AND " + MediaColumns.TITLE + " != ''");
long artist_id = getArguments().getLong(BaseColumns._ID);
where.append(" AND " + AudioColumns.ARTIST_ID + "=" + artist_id);
mWhere = where.toString();
mSortOrder = MediaColumns.TITLE;
mUri = Audio.Media.EXTERNAL_CONTENT_URI;
mFragmentGroupId = 88;
mType = TYPE_ARTIST;
mTitleColumn = MediaColumns.TITLE;
}
示例12: idForplaylist
import android.provider.MediaStore.Audio; //导入依赖的package包/类
private int idForplaylist(String name) {
Cursor cursor = MusicUtils.query(this, Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
Audio.Playlists._ID
}, Audio.Playlists.NAME + "=?", new String[] {
name
}, Audio.Playlists.NAME, 0);
int id = -1;
if (cursor != null) {
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
id = cursor.getInt(0);
}
cursor.close();
}
return id;
}
示例13: nameForId
import android.provider.MediaStore.Audio; //导入依赖的package包/类
private String nameForId(long id) {
Cursor cursor = MusicUtils.query(this, Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
Audio.Playlists.NAME
}, Audio.Playlists._ID + "=?", new String[] {
Long.valueOf(id).toString()
}, Audio.Playlists.NAME);
String name = null;
if (cursor != null) {
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
name = cursor.getString(0);
}
cursor.close();
}
return name;
}
示例14: getSongListForCursor
import android.provider.MediaStore.Audio; //导入依赖的package包/类
/**
* @param cursor
* @return
*/
public static long[] getSongListForCursor(Cursor cursor) {
if (cursor == null) {
return sEmptyList;
}
int len = cursor.getCount();
long[] list = new long[len];
cursor.moveToFirst();
int colidx = -1;
try {
colidx = cursor.getColumnIndexOrThrow(Audio.Playlists.Members.AUDIO_ID);
} catch (IllegalArgumentException ex) {
colidx = cursor.getColumnIndexOrThrow(BaseColumns._ID);
}
for (int i = 0; i < len; i++) {
list[i] = cursor.getLong(colidx);
cursor.moveToNext();
}
return list;
}
示例15: constructPartFromUri
import android.provider.MediaStore.Audio; //导入依赖的package包/类
public static PduPart constructPartFromUri(Context context, Uri uri) throws IOException, MediaTooLargeException {
PduPart part = new PduPart();
if (getMediaSize(context, uri) > MAX_MESSAGE_SIZE)
throw new MediaTooLargeException("Audio track larger than size maximum.");
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri, new String[]{Audio.Media.MIME_TYPE}, null, null, null);
if (cursor != null && cursor.moveToFirst())
part.setContentType(cursor.getString(0).getBytes());
else
throw new IOException("Unable to query content type.");
} finally {
if (cursor != null)
cursor.close();
}
part.setDataUri(uri);
part.setContentId((System.currentTimeMillis()+"").getBytes());
part.setName(("Audio" + System.currentTimeMillis()).getBytes());
return part;
}