类android.provider.MediaStore.Video.VideoColumns源码实例Demo

下面列出了怎么用android.provider.MediaStore.Video.VideoColumns的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: FireFiles   文件: StorageProvider.java
protected long getVideoForBucketCleared(long bucketId)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                VideosBucketThumbnailQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + bucketId,
                null, VideoColumns.DATE_MODIFIED + " DESC");
        if (cursor.moveToFirst()) {
            return cursor.getLong(VideosBucketThumbnailQuery._ID);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    throw new FileNotFoundException("No video found for bucket");
}
 
源代码2 项目: FireFiles   文件: StorageProvider.java
protected long getVideoForBucketCleared(long bucketId)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                VideosBucketThumbnailQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + bucketId,
                null, VideoColumns.DATE_MODIFIED + " DESC");
        if (cursor.moveToFirst()) {
            return cursor.getLong(VideosBucketThumbnailQuery._ID);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    throw new FileNotFoundException("No video found for bucket");
}
 
源代码3 项目: FireFiles   文件: StorageProvider.java
protected long getVideoForBucketCleared(long bucketId)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                VideosBucketThumbnailQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + bucketId,
                null, VideoColumns.DATE_MODIFIED + " DESC");
        if (cursor.moveToFirst()) {
            return cursor.getLong(VideosBucketThumbnailQuery._ID);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    throw new FileNotFoundException("No video found for bucket");
}
 
源代码4 项目: Camera2   文件: VideoCaptureIntentTest.java
@Override
protected void tearDown() throws Exception
{
    if (mVideoUri != null)
    {
        ContentResolver resolver = getActivity().getContentResolver();
        Uri query = mVideoUri.buildUpon().build();
        String[] projection = new String[]{VideoColumns.DATA};

        Cursor cursor = null;
        try
        {
            cursor = resolver.query(query, projection, null, null, null);
            if (cursor != null && cursor.moveToFirst())
            {
                new File(cursor.getString(0)).delete();
            }
        } finally
        {
            if (cursor != null)
            {
                cursor.close();
            }
        }

        resolver.delete(mVideoUri, null, null);
    }
    if (mFile != null)
    {
        mFile.delete();
    }
    if (mFile2 != null)
    {
        mFile2.delete();
    }
    super.tearDown();
}
 
源代码5 项目: medialibrary   文件: LocalAlbum.java
public LocalAlbum(Path path, MediaDataContext application, int bucketId,
                  boolean isImage, String name) {
    super(path, nextVersionNumber());
    mApplication = application;
    mResolver = application.getContentResolver();
    mBucketId = bucketId;
    mName = name;
    mIsImage = isImage;

    if (isImage) {
        mWhereClause = ImageColumns.BUCKET_ID + " = ?";
        mOrderClause = ImageColumns.DATE_TAKEN + " DESC, "
                + ImageColumns._ID + " DESC";
        mBaseUri = Images.Media.EXTERNAL_CONTENT_URI;
        mProjection = LocalImage.PROJECTION;
        mItemPath = LocalImage.ITEM_PATH;
    } else {
        mWhereClause = VideoColumns.BUCKET_ID + " = ?";
        mOrderClause = VideoColumns.DATE_TAKEN + " DESC, "
                + VideoColumns._ID + " DESC";
        mBaseUri = Video.Media.EXTERNAL_CONTENT_URI;
        mProjection = LocalVideo.PROJECTION;
        mItemPath = LocalVideo.ITEM_PATH;
    }

    mNotifier = new ChangeNotifier(this, mBaseUri, application);
}
 
源代码6 项目: FireFiles   文件: MediaDocumentsProvider.java
@Override
public Cursor queryRecentDocuments(String rootId, String[] projection)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));

    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        if (TYPE_IMAGES_ROOT.equals(rootId)) {
            // include all unique buckets
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImageQuery.PROJECTION, null, null, ImageColumns.DATE_MODIFIED + " DESC");
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            while (cursor.moveToNext() && result.getCount() < 64) {
                includeImage(result, cursor);
            }
        } else if (TYPE_VIDEOS_ROOT.equals(rootId)) {
            // include all unique buckets
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideoQuery.PROJECTION, null, null, VideoColumns.DATE_MODIFIED + " DESC");
            copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
            while (cursor.moveToNext() && result.getCount() < 64) {
                includeVideo(result, cursor);
            }
        } else {
            throw new UnsupportedOperationException("Unsupported root " + rootId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
源代码7 项目: FireFiles   文件: StorageProvider.java
protected long getVideoForPathCleared(String path)throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                VideosBucketThumbnailQuery.PROJECTION, VideoColumns.DATA + "=? ",
                new String[] { path.replaceAll("'", "''") }, VideoColumns.DATE_MODIFIED + " DESC");
        if (cursor.moveToFirst()) {
            return cursor.getLong(VideosBucketThumbnailQuery._ID);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    throw new FileNotFoundException("No video found for bucket");
}
 
源代码8 项目: FireFiles   文件: MediaDocumentsProvider.java
@Override
public Cursor queryRecentDocuments(String rootId, String[] projection)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));

    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        if (TYPE_IMAGES_ROOT.equals(rootId)) {
            // include all unique buckets
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImageQuery.PROJECTION, null, null, ImageColumns.DATE_MODIFIED + " DESC");
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            while (cursor.moveToNext() && result.getCount() < 64) {
                includeImage(result, cursor);
            }
        } else if (TYPE_VIDEOS_ROOT.equals(rootId)) {
            // include all unique buckets
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideoQuery.PROJECTION, null, null, VideoColumns.DATE_MODIFIED + " DESC");
            copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
            while (cursor.moveToNext() && result.getCount() < 64) {
                includeVideo(result, cursor);
            }
        } else {
            throw new UnsupportedOperationException("Unsupported root " + rootId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
源代码9 项目: FireFiles   文件: StorageProvider.java
protected long getVideoForPathCleared(String path)throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                VideosBucketThumbnailQuery.PROJECTION, VideoColumns.DATA + "=? ",
                new String[] { path.replaceAll("'", "''") }, VideoColumns.DATE_MODIFIED + " DESC");
        if (cursor.moveToFirst()) {
            return cursor.getLong(VideosBucketThumbnailQuery._ID);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    throw new FileNotFoundException("No video found for bucket");
}
 
源代码10 项目: FireFiles   文件: MediaDocumentsProvider.java
@Override
public Cursor queryRecentDocuments(String rootId, String[] projection)
        throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));

    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        if (TYPE_IMAGES_ROOT.equals(rootId)) {
            // include all unique buckets
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImageQuery.PROJECTION, null, null, ImageColumns.DATE_MODIFIED + " DESC");
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            while (cursor.moveToNext() && result.getCount() < 64) {
                includeImage(result, cursor);
            }
        } else if (TYPE_VIDEOS_ROOT.equals(rootId)) {
            // include all unique buckets
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideoQuery.PROJECTION, null, null, VideoColumns.DATE_MODIFIED + " DESC");
            copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
            while (cursor.moveToNext() && result.getCount() < 64) {
                includeVideo(result, cursor);
            }
        } else {
            throw new UnsupportedOperationException("Unsupported root " + rootId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
源代码11 项目: FireFiles   文件: StorageProvider.java
protected long getVideoForPathCleared(String path)throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    Cursor cursor = null;
    try {
        cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                VideosBucketThumbnailQuery.PROJECTION, VideoColumns.DATA + "=? ",
                new String[] { path.replaceAll("'", "''") }, VideoColumns.DATE_MODIFIED + " DESC");
        if (cursor.moveToFirst()) {
            return cursor.getLong(VideosBucketThumbnailQuery._ID);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    throw new FileNotFoundException("No video found for bucket");
}
 
源代码12 项目: FireFiles   文件: MediaDocumentsProvider.java
@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final Ident ident = getIdentForDocId(docId);

    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        if (TYPE_IMAGES_ROOT.equals(ident.type)) {
            // single root
            includeImagesRootDocument(result);
        } else if (TYPE_IMAGES_BUCKET.equals(ident.type)) {
            // single bucket
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImagesBucketQuery.PROJECTION, ImageColumns.BUCKET_ID + "=" + ident.id,
                    null, ImagesBucketQuery.SORT_ORDER);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeImagesBucket(result, cursor);
            }
        } else if (TYPE_IMAGE.equals(ident.type)) {
            // single image
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImageQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeImage(result, cursor);
            }
        } else if (TYPE_VIDEOS_ROOT.equals(ident.type)) {
            // single root
            includeVideosRootDocument(result);
        } else if (TYPE_VIDEOS_BUCKET.equals(ident.type)) {
            // single bucket
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideosBucketQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + ident.id,
                    null, VideosBucketQuery.SORT_ORDER);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeVideosBucket(result, cursor);
            }
        } else if (TYPE_VIDEO.equals(ident.type)) {
            // single video
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideoQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeVideo(result, cursor);
            }
        } else if (TYPE_AUDIO_ROOT.equals(ident.type)) {
            // single root
            includeAudioRootDocument(result);
        } else if (TYPE_ARTIST.equals(ident.type)) {
            // single artist
            cursor = resolver.query(Artists.EXTERNAL_CONTENT_URI,
                    ArtistQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Artists.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeArtist(result, cursor);
            }
        } else if (TYPE_ALBUM.equals(ident.type)) {
            // single album
            cursor = resolver.query(Albums.EXTERNAL_CONTENT_URI,
                    AlbumQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Albums.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeAlbum(result, cursor);
            }
        } else if (TYPE_AUDIO.equals(ident.type)) {
            // single song
            cursor = resolver.query(Audio.Media.EXTERNAL_CONTENT_URI,
                    SongQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Audio.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeAudio(result, cursor);
            }
        } else {
            throw new UnsupportedOperationException("Unsupported document " + docId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
源代码13 项目: FireFiles   文件: MediaDocumentsProvider.java
@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final Ident ident = getIdentForDocId(docId);

    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        if (TYPE_IMAGES_ROOT.equals(ident.type)) {
            // single root
            includeImagesRootDocument(result);
        } else if (TYPE_IMAGES_BUCKET.equals(ident.type)) {
            // single bucket
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImagesBucketQuery.PROJECTION, ImageColumns.BUCKET_ID + "=" + ident.id,
                    null, ImagesBucketQuery.SORT_ORDER);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeImagesBucket(result, cursor);
            }
        } else if (TYPE_IMAGE.equals(ident.type)) {
            // single image
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImageQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeImage(result, cursor);
            }
        } else if (TYPE_VIDEOS_ROOT.equals(ident.type)) {
            // single root
            includeVideosRootDocument(result);
        } else if (TYPE_VIDEOS_BUCKET.equals(ident.type)) {
            // single bucket
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideosBucketQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + ident.id,
                    null, VideosBucketQuery.SORT_ORDER);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeVideosBucket(result, cursor);
            }
        } else if (TYPE_VIDEO.equals(ident.type)) {
            // single video
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideoQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeVideo(result, cursor);
            }
        } else if (TYPE_AUDIO_ROOT.equals(ident.type)) {
            // single root
            includeAudioRootDocument(result);
        } else if (TYPE_ARTIST.equals(ident.type)) {
            // single artist
            cursor = resolver.query(Artists.EXTERNAL_CONTENT_URI,
                    ArtistQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Artists.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeArtist(result, cursor);
            }
        } else if (TYPE_ALBUM.equals(ident.type)) {
            // single album
            cursor = resolver.query(Albums.EXTERNAL_CONTENT_URI,
                    AlbumQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Albums.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeAlbum(result, cursor);
            }
        } else if (TYPE_AUDIO.equals(ident.type)) {
            // single song
            cursor = resolver.query(Audio.Media.EXTERNAL_CONTENT_URI,
                    SongQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Audio.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeAudio(result, cursor);
            }
        } else {
            throw new UnsupportedOperationException("Unsupported document " + docId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
源代码14 项目: FireFiles   文件: MediaDocumentsProvider.java
@Override
public Cursor queryDocument(String docId, String[] projection) throws FileNotFoundException {
    final ContentResolver resolver = getContext().getContentResolver();
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    final Ident ident = getIdentForDocId(docId);

    final long token = Binder.clearCallingIdentity();
    Cursor cursor = null;
    try {
        if (TYPE_IMAGES_ROOT.equals(ident.type)) {
            // single root
            includeImagesRootDocument(result);
        } else if (TYPE_IMAGES_BUCKET.equals(ident.type)) {
            // single bucket
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImagesBucketQuery.PROJECTION, ImageColumns.BUCKET_ID + "=" + ident.id,
                    null, ImagesBucketQuery.SORT_ORDER);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeImagesBucket(result, cursor);
            }
        } else if (TYPE_IMAGE.equals(ident.type)) {
            // single image
            cursor = resolver.query(Images.Media.EXTERNAL_CONTENT_URI,
                    ImageQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeImage(result, cursor);
            }
        } else if (TYPE_VIDEOS_ROOT.equals(ident.type)) {
            // single root
            includeVideosRootDocument(result);
        } else if (TYPE_VIDEOS_BUCKET.equals(ident.type)) {
            // single bucket
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideosBucketQuery.PROJECTION, VideoColumns.BUCKET_ID + "=" + ident.id,
                    null, VideosBucketQuery.SORT_ORDER);
            copyNotificationUri(result, Images.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeVideosBucket(result, cursor);
            }
        } else if (TYPE_VIDEO.equals(ident.type)) {
            // single video
            cursor = resolver.query(Video.Media.EXTERNAL_CONTENT_URI,
                    VideoQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Video.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeVideo(result, cursor);
            }
        } else if (TYPE_AUDIO_ROOT.equals(ident.type)) {
            // single root
            includeAudioRootDocument(result);
        } else if (TYPE_ARTIST.equals(ident.type)) {
            // single artist
            cursor = resolver.query(Artists.EXTERNAL_CONTENT_URI,
                    ArtistQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Artists.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeArtist(result, cursor);
            }
        } else if (TYPE_ALBUM.equals(ident.type)) {
            // single album
            cursor = resolver.query(Albums.EXTERNAL_CONTENT_URI,
                    AlbumQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Albums.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeAlbum(result, cursor);
            }
        } else if (TYPE_AUDIO.equals(ident.type)) {
            // single song
            cursor = resolver.query(Audio.Media.EXTERNAL_CONTENT_URI,
                    SongQuery.PROJECTION, BaseColumns._ID + "=" + ident.id, null,
                    null);
            copyNotificationUri(result, Audio.Media.EXTERNAL_CONTENT_URI);
            if (cursor.moveToFirst()) {
                includeAudio(result, cursor);
            }
        } else {
            throw new UnsupportedOperationException("Unsupported document " + docId);
        }
    } finally {
        IoUtils.closeQuietly(cursor);
        Binder.restoreCallingIdentity(token);
    }
    return result;
}
 
 类所在包
 类方法
 同包方法