当前位置: 首页>>代码示例>>Java>>正文


Java PlaylistsColumns类代码示例

本文整理汇总了Java中android.provider.MediaStore.Audio.PlaylistsColumns的典型用法代码示例。如果您正苦于以下问题:Java PlaylistsColumns类的具体用法?Java PlaylistsColumns怎么用?Java PlaylistsColumns使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PlaylistsColumns类属于android.provider.MediaStore.Audio包,在下文中一共展示了PlaylistsColumns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name    The name of the new playlist.
 * @return A new playlist ID.
 */
public static final long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[]{
                PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        if (cursor.getCount() <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
        return -1;
    }
    return -1;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:30,代码来源:MusicUtils.java

示例2: getIdForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * Returns The ID for a playlist.
 *
 * @param context The {@link Context} to use.
 * @param name    The name of the playlist.
 * @return The ID for a playlist.
 */
public static final long getIdForPlaylist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, new String[]{
                    BaseColumns._ID
            }, PlaylistsColumns.NAME + "=?", new String[]{
                    name
            }, PlaylistsColumns.NAME);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:26,代码来源:MusicUtils.java

示例3: getNameForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param id      The id of the playlist.
 * @return The name for a playlist.
 */
public static final String getNameForPlaylist(final Context context, final long id) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
            new String[]{PlaylistsColumns.NAME},
            BaseColumns._ID + "=?",
            new String[]{Long.toString(id)},
            null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                return cursor.getString(0);
            }
        } finally {
            cursor.close();
        }
    }
    // nothing found
    return null;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:25,代码来源:MusicUtils.java

示例4: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context
 * @param name
 * @return
 */
public static long createPlaylist(Context context, String name) {

    if (name != null && name.length() > 0) {
        ContentResolver resolver = context.getContentResolver();
        String[] cols = new String[] {
            PlaylistsColumns.NAME
        };
        String whereclause = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cur = resolver.query(Audio.Playlists.EXTERNAL_CONTENT_URI, cols, whereclause,
                null, null);
        if (cur.getCount() <= 0) {
            ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            Uri uri = resolver.insert(Audio.Playlists.EXTERNAL_CONTENT_URI, values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        return -1;
    }
    return -1;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:26,代码来源:MusicUtils.java

示例5: getFavoritesId

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context
 * @return
 */
public static long getFavoritesId(Context context) {
    long favorites_id = -1;
    String favorites_where = PlaylistsColumns.NAME + "='" + "Favorites" + "'";
    String[] favorites_cols = new String[] {
        BaseColumns._ID
    };
    Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    Cursor cursor = query(context, favorites_uri, favorites_cols, favorites_where, null, null);
    if (cursor.getCount() <= 0) {
        favorites_id = createPlaylist(context, "Favorites");
    } else {
        cursor.moveToFirst();
        favorites_id = cursor.getLong(0);
        cursor.close();
    }
    return favorites_id;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:22,代码来源:MusicUtils.java

示例6: removeFromFavorites

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context
 * @param id
 */
public static void removeFromFavorites(Context context, long id) {
    long favorites_id;
    if (id < 0) {
    } else {
        ContentResolver resolver = context.getContentResolver();
        String favorites_where = PlaylistsColumns.NAME + "='" + PLAYLIST_NAME_FAVORITES + "'";
        String[] favorites_cols = new String[] {
            BaseColumns._ID
        };
        Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
        Cursor cursor = resolver.query(favorites_uri, favorites_cols, favorites_where, null,
                null);
        if (cursor.getCount() <= 0) {
            favorites_id = createPlaylist(context, PLAYLIST_NAME_FAVORITES);
        } else {
            cursor.moveToFirst();
            favorites_id = cursor.getLong(0);
            cursor.close();
        }
        Uri uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
        resolver.delete(uri, Playlists.Members.AUDIO_ID + "=" + id, null);
    }
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:28,代码来源:MusicUtils.java

示例7: getPlaylistName

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param playlist_id
 * @return playlist name
 */
public static String getPlaylistName(Context mContext, long playlist_id) {
    String where = BaseColumns._ID + "=" + playlist_id;
    String[] cols = new String[] {
        PlaylistsColumns.NAME
    };
    Uri uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    Cursor cursor = mContext.getContentResolver().query(uri, cols, where, null, null);
    if (cursor == null){
        return "";
    }
    if (cursor.getCount() <= 0)
        return "";
    cursor.moveToFirst();
    String name = cursor.getString(0);
    cursor.close();
    return name;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:22,代码来源:MusicUtils.java

示例8: getIdForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * Returns The ID for a playlist.
 *
 * @param context The {@link Context} to use.
 * @param name The name of the playlist.
 * @return The ID for a playlist.
 */
public static long getIdForPlaylist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, PlaylistsColumns.NAME + "=?", new String[] {
                name
            }, PlaylistsColumns.NAME);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:26,代码来源:MusicUtils.java

示例9: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name The name of the new playlist.
 * @return A new playlist ID.
 */
public static long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[] {
            PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        int count = 1;
        if (cursor != null) {
            count = cursor.getCount();
            cursor.close();
        }
        if (count <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        return -1;
    }
    return -1;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:31,代码来源:MusicUtils.java

示例10: getIdForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * Returns The ID for a playlist.
 * 
 * @param context The {@link Context} to use.
 * @param name The name of the playlist.
 * @return The ID for a playlist.
 */
public static final long getIdForPlaylist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, PlaylistsColumns.NAME + "=?", new String[] {
                name
            }, PlaylistsColumns.NAME);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:26,代码来源:MusicUtils.java

示例11: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name The name of the new playlist.
 * @return A new playlist ID.
 */
public static final long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[] {
            PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        if (cursor.getCount() <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
        return -1;
    }
    return -1;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:30,代码来源:MusicUtils.java

示例12: getPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@NonNull
public static Playlist getPlaylist(@NonNull final Context context, final String playlistName) {
    return getPlaylist(makePlaylistCursor(
            context,
            PlaylistsColumns.NAME + "=?",
            new String[]{
                    playlistName
            }
    ));
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:11,代码来源:PlaylistLoader.java

示例13: makePlaylistCursor

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@Nullable
public static Cursor makePlaylistCursor(@NonNull final Context context, final String selection, final String[] values) {
    try {
        return context.getContentResolver().query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                new String[]{
                    /* 0 */
                        BaseColumns._ID,
                    /* 1 */
                        PlaylistsColumns.NAME
                }, selection, values, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:15,代码来源:PlaylistLoader.java

示例14: makePlaylistCursor

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
public static final Cursor makePlaylistCursor(final Context context) {
    return context.getContentResolver().query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
            new String[]{
                    BaseColumns._ID,
                    PlaylistsColumns.NAME
            }, null, null, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:8,代码来源:PlaylistLoader.java

示例15: getPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@NonNull
public static Observable<Playlist> getPlaylist(@NonNull final Context context, final String playlistName) {
    return getPlaylist(makePlaylistCursor(
            context,
            PlaylistsColumns.NAME + "=?",
            new String[]{
                    playlistName
            }
    ));
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:11,代码来源:PlaylistLoader.java


注:本文中的android.provider.MediaStore.Audio.PlaylistsColumns类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。