本文整理汇总了Java中android.provider.MediaStore.Video.VideoColumns类的典型用法代码示例。如果您正苦于以下问题:Java VideoColumns类的具体用法?Java VideoColumns怎么用?Java VideoColumns使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VideoColumns类属于android.provider.MediaStore.Video包,在下文中一共展示了VideoColumns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVideoForBucketCleared
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
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: getMimeTypeForMedia
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
public static String getMimeTypeForMedia(ContentResolver cr, int id,
boolean isImage) {
Cursor cursor;
if(isImage)
cursor = cr.query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String [] {MediaStore.Images.Media.MIME_TYPE}, ImageColumns._ID+" = ?",
new String [] { String.valueOf(id) }, null);
else
cursor = cr.query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
new String [] {MediaStore.Video.Media.MIME_TYPE}, VideoColumns._ID+" = ?",
new String [] { String.valueOf(id) }, null);
try {
if(!cursor.moveToFirst())
return null;
return cursor.getString(0);
}
finally {
cursor.close();
}
}
示例3: getDataFilepathForMedia
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
public static String getDataFilepathForMedia(ContentResolver cr, int id, boolean isImage)
{
Cursor cursor;
if(isImage)
cursor = cr.query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String [] {MediaStore.Images.Media.DATA}, ImageColumns._ID+" = ?",
new String [] { String.valueOf(id) }, null);
else
cursor = cr.query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
new String [] {MediaStore.Video.Media.DATA}, VideoColumns._ID+" = ?",
new String [] { String.valueOf(id) }, null);
try {
if(!cursor.moveToFirst())
return null;
return cursor.getString(0);
}
finally {
cursor.close();
}
}
示例4: LocalAlbum
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
public LocalAlbum(Path path, GalleryApp 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);
}
示例5: queryRecentDocuments
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
@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;
}
示例6: getVideoForPathCleared
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
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");
}
示例7: LocalAlbum
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
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);
}
示例8: intTodbv
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
public static Uri intTodbv(Context context, String type, String title,
int orientation, String path, Long length) {
// Insert into MediaStore.
ContentValues values = new ContentValues(9);
values.put(VideoColumns.TITLE, title);
values.put(VideoColumns.DISPLAY_NAME, title + ".mp4");
values.put(VideoColumns.DATE_TAKEN, new Date().toLocaleString());
values.put(VideoColumns.MIME_TYPE, type);
// values.put(VideoColumns., orientation);
values.put(VideoColumns.DATA, path);
values.put(VideoColumns.SIZE, length);
// values.put(ImageColumns.WIDTH, width);
// values.put(ImageColumns.HEIGHT, height);
// if (location != null) {
// values.put(ImageColumns.LATITUDE, location.getLatitude());
// values.put(ImageColumns.LONGITUDE, location.getLongitude());
// }
Uri uri = null;
int stromode = StoredData.getInt(StoredData.M_STORAGEMODE, 0);
// if (stromode == 0) {
// uri = context.getContentResolver().insert(
// Video.Media.INTERNAL_CONTENT_URI, values);
// } else {
uri = context.getContentResolver().insert(
Video.Media.EXTERNAL_CONTENT_URI, values);
// }
context.sendBroadcast(new Intent("android.hardware.action.NEW_VIDEO",
uri));
if (uri == null) {
return null;
}
return uri;
}
示例9: onActivityResult
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
@Override
protected void onActivityResult(Context context, int requestCode, int resultCode, Intent data) {
if (resultCode != Activity.RESULT_OK) {
return;
}
Cursor cursor = mExecutor.getContext().getContentResolver().query(data.getData(), null, null, null, null);
if (cursor == null || !cursor.moveToNext()) {
return;
}
String path = cursor.getString(cursor.getColumnIndex(VideoColumns.DATA));
MakeVideoListener listener = getListener(MakeVideoListener.class);
if (listener != null) {
listener.onComplete(Uri.fromFile(new File(path)));
}
}
示例10: mediaExists
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
/**
* True if the media exists, false otherwise
* @param context
* @param id
* @param isImage false == video
* @return
*/
public static boolean mediaExists(Context context, int id, boolean isImage) {
ContentResolver cr = context.getContentResolver();
Cursor cursor;
if(isImage)
cursor = cr.query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
new String [] {MediaStore.Images.Media.DATA}, ImageColumns._ID+" = ?",
new String [] { String.valueOf(id) }, null);
else
cursor = cr.query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
new String [] {MediaStore.Video.Media.DATA}, VideoColumns._ID+" = ?",
new String [] { String.valueOf(id) }, null);
try {
if(!cursor.moveToFirst())
return false;
if(!new File(cursor.getString(0)).exists())
return false;
}
finally {
cursor.close();
}
return true;
}
示例11: getSaveDirectory
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
private static File getSaveDirectory(ContentResolver contentResolver, Uri uri) {
final File[] dir = new File[1];
querySource(contentResolver, uri,
new String[] { VideoColumns.DATA },
new ContentResolverQueryCallback() {
@Override
public void onCursorResult(Cursor cursor) {
dir[0] = new File(cursor.getString(0)).getParentFile();
}
});
return dir[0];
}
示例12: LocalAlbum
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
public LocalAlbum(Path path, WoTuApp application, long bucketId,
boolean isImage, String name) {
super(path, nextVersionNumber());
mApplication = application;
mResolver = application.getContentResolver();
mBucketId = bucketId;
mName = getLocalizedName(application.getResources(), bucketId, 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 DataNotifier(this, mBaseUri, application);
}
示例13: getLatestMedia
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
private Media getLatestMedia(boolean video) {
Media media = null;
Uri baseUri = video ? Video.Media.EXTERNAL_CONTENT_URI
: MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1")
.build();
String[] projection = video ? new String[] { VideoColumns._ID,
VideoColumns.DATE_TAKEN } : new String[] { ImageColumns._ID,
ImageColumns.DATE_TAKEN, ImageColumns.ORIENTATION };
String selection = video ? "" : ImageColumns.MIME_TYPE
+ "='image/jpeg'";
String order = video ? VideoColumns.DATE_TAKEN + " DESC,"
+ VideoColumns._ID + " DESC" : ImageColumns.DATE_TAKEN
+ " DESC," + ImageColumns._ID + " DESC";
Cursor cursor = null;
try {
cursor = getContentResolver().query(query, projection, selection,
null, order);
if (cursor != null && cursor.moveToFirst()) {
long id = cursor.getLong(0);
long date = cursor.getLong(1);
int orientation = video ? 0 : cursor.getInt(2);
Uri uri = ContentUris.withAppendedId(baseUri, id);
if (MyDebug.LOG)
Log.d(TAG, "found most recent uri for "
+ (video ? "video" : "images") + ": " + uri);
media = new Media(id, video, uri, date, orientation);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return media;
}
示例14: getVideoInfoDeprecated
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
/**
* 获取单个文件的视频信息
* @param videoPath
* @return 视频信息
*/
public VideoInfo getVideoInfoDeprecated(String videoPath) {
Log.w(TAG, "[getVideoInfo]传入路径: "+videoPath);
VideoInfo info = null;
final int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
if (sdkVersion < 10){
String where = MediaColumns.DATA + "=?";
String[] selectionArgs = new String[] { videoPath };
try
{
if(context != null){
Cursor cursor = context.getContentResolver().query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
null,
where,
selectionArgs,
null);
if (cursor != null) {
cursor.moveToFirst();
String title = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaColumns.TITLE));
String album = cursor
.getString(cursor
.getColumnIndexOrThrow(VideoColumns.ALBUM));
String artist = cursor
.getString(cursor
.getColumnIndexOrThrow(VideoColumns.ARTIST));
String displayName = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaColumns.DISPLAY_NAME));
String mimeType = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaColumns.MIME_TYPE));
String path = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaColumns.DATA));
long duration = cursor
.getInt(cursor
.getColumnIndexOrThrow(VideoColumns.DURATION));
long size = cursor
.getLong(cursor
.getColumnIndexOrThrow(MediaColumns.SIZE));
}
}
} catch (Exception e)
{
// TODO: handle exception
}
}
return info;
}
示例15: insertContent
import android.provider.MediaStore.Video.VideoColumns; //导入依赖的package包/类
/**
* Insert the content (saved file) with proper video properties.
*/
public static Uri insertContent(SaveVideoFileInfo mDstFileInfo,
ContentResolver contentResolver, Uri uri ) {
long nowInMs = System.currentTimeMillis();
long nowInSec = nowInMs / 1000;
final ContentValues values = new ContentValues(13);
values.put(Video.Media.TITLE, mDstFileInfo.mFileName);
values.put(Video.Media.DISPLAY_NAME, mDstFileInfo.mFile.getName());
values.put(Video.Media.MIME_TYPE, "video/mp4");
values.put(Video.Media.DATE_TAKEN, nowInMs);
values.put(Video.Media.DATE_MODIFIED, nowInSec);
values.put(Video.Media.DATE_ADDED, nowInSec);
values.put(Video.Media.DATA, mDstFileInfo.mFile.getAbsolutePath());
values.put(Video.Media.SIZE, mDstFileInfo.mFile.length());
int durationMs = retriveVideoDurationMs(mDstFileInfo.mFile.getPath());
values.put(Video.Media.DURATION, durationMs);
// Copy the data taken and location info from src.
String[] projection = new String[] {
VideoColumns.DATE_TAKEN,
VideoColumns.LATITUDE,
VideoColumns.LONGITUDE,
VideoColumns.RESOLUTION,
};
// Copy some info from the source file.
querySource(contentResolver, uri, projection,
new ContentResolverQueryCallback() {
@Override
public void onCursorResult(Cursor cursor) {
long timeTaken = cursor.getLong(0);
if (timeTaken > 0) {
values.put(Video.Media.DATE_TAKEN, timeTaken);
}
double latitude = cursor.getDouble(1);
double longitude = cursor.getDouble(2);
// TODO: Change || to && after the default location
// issue is
// fixed.
if ((latitude != 0f) || (longitude != 0f)) {
values.put(Video.Media.LATITUDE, latitude);
values.put(Video.Media.LONGITUDE, longitude);
}
values.put(Video.Media.RESOLUTION, cursor.getString(3));
}
});
return contentResolver.insert(Video.Media.EXTERNAL_CONTENT_URI, values);
}