Java 类android.provider.MediaStore.Video 实例源码
项目:VideoRecorder-master
文件:Util.java
public static String createFinalPath(Context context)
{
long dateTaken = System.currentTimeMillis();
String title = CONSTANTS.FILE_START_NAME + dateTaken;
String filename = title + CONSTANTS.VIDEO_EXTENSION;
String filePath = genrateFilePath(context,String.valueOf(dateTaken), true, null);
ContentValues values = new ContentValues(7);
values.put(Video.Media.TITLE, title);
values.put(Video.Media.DISPLAY_NAME, filename);
values.put(Video.Media.DATE_TAKEN, dateTaken);
values.put(Video.Media.MIME_TYPE, "video/3gpp");
values.put(Video.Media.DATA, filePath);
videoContentValues = values;
return filePath;
}
项目:easyfilemanager
文件: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");
}
项目:easyfilemanager
文件:StorageProvider.java
protected AssetFileDescriptor openVideoThumbnailCleared(long id, CancellationSignal signal)
throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
Cursor cursor = null;
try {
cursor = resolver.query(Video.Thumbnails.EXTERNAL_CONTENT_URI,
VideoThumbnailQuery.PROJECTION, Video.Thumbnails.VIDEO_ID + "=" + id, null,
null);
if (cursor.moveToFirst()) {
final String data = cursor.getString(VideoThumbnailQuery._DATA);
return new AssetFileDescriptor(ParcelFileDescriptor.open(
new File(data), ParcelFileDescriptor.MODE_READ_ONLY), 0,
AssetFileDescriptor.UNKNOWN_LENGTH);
}
} finally {
IoUtils.closeQuietly(cursor);
}
return null;
}
项目:easyfilemanager
文件:StorageProvider.java
protected AssetFileDescriptor openOrCreateVideoThumbnailCleared(
long id, CancellationSignal signal) throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
AssetFileDescriptor afd = openVideoThumbnailCleared(id, signal);
if (afd == null) {
// No thumbnail yet, so generate. This is messy, since we drop the
// Bitmap on the floor, but its the least-complicated way.
final BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
Video.Thumbnails.getThumbnail(resolver, id, Video.Thumbnails.MINI_KIND, opts);
afd = openVideoThumbnailCleared(id, signal);
}
return afd;
}
项目:medialibrary
文件:BucketHelper.java
private static BucketEntry[] loadBucketEntriesFromImagesAndVideoTable(
ThreadPool.JobContext jc, ContentResolver resolver, int type) {
HashMap<Integer, BucketEntry> buckets = new HashMap<Integer, BucketEntry>(64);
if ((type & MediaObject.MEDIA_TYPE_IMAGE) != 0) {
updateBucketEntriesFromTable(
jc, resolver, Images.Media.EXTERNAL_CONTENT_URI, buckets);
}
if ((type & MediaObject.MEDIA_TYPE_VIDEO) != 0) {
updateBucketEntriesFromTable(
jc, resolver, Video.Media.EXTERNAL_CONTENT_URI, buckets);
}
BucketEntry[] entries = buckets.values().toArray(new BucketEntry[buckets.size()]);
Arrays.sort(entries, new Comparator<BucketEntry>() {
@Override
public int compare(BucketEntry a, BucketEntry b) {
// sorted by dateTaken in descending order
return b.dateTaken - a.dateTaken;
}
});
return entries;
}
项目:medialibrary
文件:LocalVideo.java
public LocalVideo(Path path, MediaDataContext context, int id) {
super(path, nextVersionNumber());
mApplication = context;
ContentResolver resolver = mApplication.getContentResolver();
Uri uri = Video.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = LocalAlbum.getItemCursor(resolver, uri, PROJECTION, id);
if (cursor == null) {
throw new RuntimeException("cannot get cursor for: " + path);
}
try {
if (cursor.moveToNext()) {
loadFromCursor(cursor);
} else {
throw new RuntimeException("cannot find data for: " + path);
}
} finally {
cursor.close();
}
}
项目: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");
}
项目:FireFiles
文件:StorageProvider.java
protected AssetFileDescriptor openVideoThumbnailCleared(long id, CancellationSignal signal)
throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
Cursor cursor = null;
try {
cursor = resolver.query(Video.Thumbnails.EXTERNAL_CONTENT_URI,
VideoThumbnailQuery.PROJECTION, Video.Thumbnails.VIDEO_ID + "=" + id, null,
null);
if (cursor.moveToFirst()) {
final String data = cursor.getString(VideoThumbnailQuery._DATA);
return new AssetFileDescriptor(ParcelFileDescriptor.open(
new File(data), ParcelFileDescriptor.MODE_READ_ONLY), 0,
AssetFileDescriptor.UNKNOWN_LENGTH);
}
} finally {
IoUtils.closeQuietly(cursor);
}
return null;
}
项目:FireFiles
文件:StorageProvider.java
protected AssetFileDescriptor openOrCreateVideoThumbnailCleared(
long id, CancellationSignal signal) throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
AssetFileDescriptor afd = openVideoThumbnailCleared(id, signal);
if (afd == null) {
// No thumbnail yet, so generate. This is messy, since we drop the
// Bitmap on the floor, but its the least-complicated way.
final BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
Video.Thumbnails.getThumbnail(resolver, id, Video.Thumbnails.MINI_KIND, opts);
afd = openVideoThumbnailCleared(id, signal);
}
return afd;
}
项目:simple-share-android
文件: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");
}
项目:simple-share-android
文件:StorageProvider.java
protected AssetFileDescriptor openVideoThumbnailCleared(long id, CancellationSignal signal)
throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
Cursor cursor = null;
try {
cursor = resolver.query(Video.Thumbnails.EXTERNAL_CONTENT_URI,
VideoThumbnailQuery.PROJECTION, Video.Thumbnails.VIDEO_ID + "=" + id, null,
null);
if (cursor.moveToFirst()) {
final String data = cursor.getString(VideoThumbnailQuery._DATA);
return new AssetFileDescriptor(ParcelFileDescriptor.open(
new File(data), ParcelFileDescriptor.MODE_READ_ONLY), 0,
AssetFileDescriptor.UNKNOWN_LENGTH);
}
} finally {
IoUtils.closeQuietly(cursor);
}
return null;
}
项目:simple-share-android
文件:StorageProvider.java
protected AssetFileDescriptor openOrCreateVideoThumbnailCleared(
long id, CancellationSignal signal) throws FileNotFoundException {
final ContentResolver resolver = getContext().getContentResolver();
AssetFileDescriptor afd = openVideoThumbnailCleared(id, signal);
if (afd == null) {
// No thumbnail yet, so generate. This is messy, since we drop the
// Bitmap on the floor, but its the least-complicated way.
final BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
Video.Thumbnails.getThumbnail(resolver, id, Video.Thumbnails.MINI_KIND, opts);
afd = openVideoThumbnailCleared(id, signal);
}
return afd;
}
项目:droidddle
文件:BitmapManager.java
public synchronized void cancelThreadDecoding(Thread t, ContentResolver cr) {
ThreadStatus status = getOrCreateThreadStatus(t);
status.mState = State.CANCEL;
if (status.mOptions != null) {
status.mOptions.requestCancelDecode();
}
// Wake up threads in waiting list
notifyAll();
// Since our cancel request can arrive MediaProvider earlier than getThumbnail request,
// we use mThumbRequesting flag to make sure our request does cancel the request.
try {
synchronized (status) {
while (status.mThumbRequesting) {
Images.Thumbnails.cancelThumbnailRequest(cr, -1, t.getId());
Video.Thumbnails.cancelThumbnailRequest(cr, -1, t.getId());
status.wait(200);
}
}
} catch (InterruptedException ex) {
// ignore it.
}
}
项目:droidddle
文件:BitmapManager.java
public Bitmap getThumbnail(ContentResolver cr, long origId, int kind, BitmapFactory.Options options, boolean isVideo) {
Thread t = Thread.currentThread();
ThreadStatus status = getOrCreateThreadStatus(t);
if (!canThreadDecoding(t)) {
Log.d(TAG, "Thread " + t + " is not allowed to decode.");
return null;
}
try {
synchronized (status) {
status.mThumbRequesting = true;
}
if (isVideo) {
return Video.Thumbnails.getThumbnail(cr, origId, t.getId(), kind, null);
} else {
return Images.Thumbnails.getThumbnail(cr, origId, t.getId(), kind, null);
}
} finally {
synchronized (status) {
status.mThumbRequesting = false;
status.notifyAll();
}
}
}
项目:In-Time-Android-Native-App-
文件:MovieSingle.java
private void shareVideo(){
String outputFile = currentTimelap.getPath();
ContentValues content = new ContentValues(4);
content.put(Video.VideoColumns.TITLE, currentTimelap.getName());
content.put(Video.VideoColumns.DATE_ADDED,
System.currentTimeMillis() / 1000);
content.put(Video.Media.MIME_TYPE, "video/mp4");
content.put(MediaStore.Video.Media.DATA, outputFile);
ContentResolver resolver = getContentResolver();
Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
content);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("video/*");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "Share using"));
}
项目:DeviceConnect-Android
文件:AudioRecorderActivity.java
@Override
protected void onPause() {
super.onPause();
// 受信を停止.
unregisterReceiver(mReceiver);
if (checkAudioFile()) {
// Contents Providerに登録.
ContentResolver resolver = this.getApplicationContext().getContentResolver();
ContentValues values = new ContentValues();
values.put(Video.Media.TITLE, mFileName);
values.put(Video.Media.DISPLAY_NAME, mFileName);
values.put(Video.Media.ARTIST, "DeviceConnect");
values.put(Video.Media.MIME_TYPE, AudioConst.FORMAT_TYPE);
values.put(Video.Media.DATA, mFile.toString());
resolver.insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values);
}
releaseMediaRecorder();
}
项目:Camera2
文件:VideoModule.java
private void saveVideo() {
if (mVideoFileDescriptor == null) {
long duration = SystemClock.uptimeMillis() - mRecordingStartTime;
if (duration > 0) {
//
} else {
Log.w(TAG, "Video duration <= 0 : " + duration);
}
mCurrentVideoValues.put(Video.Media.SIZE, new File(mCurrentVideoFilename).length());
mCurrentVideoValues.put(Video.Media.DURATION, duration);
getServices().getMediaSaver().addVideo(mCurrentVideoFilename,
mCurrentVideoValues, mOnVideoSavedListener, mContentResolver);
logVideoCapture(duration);
}
mCurrentVideoValues = null;
}
项目:Camera2
文件:MediaSaverImpl.java
@Override
protected Uri doInBackground(Void... v) {
Uri uri = null;
try {
Uri videoTable = Uri.parse(VIDEO_BASE_URI);
uri = resolver.insert(videoTable, values);
// Rename the video file to the final name. This avoids other
// apps reading incomplete data. We need to do it after we are
// certain that the previous insert to MediaProvider is completed.
String finalName = values.getAsString(Video.Media.DATA);
File finalFile = new File(finalName);
if (new File(path).renameTo(finalFile)) {
path = finalName;
}
resolver.update(uri, values, null, null);
} catch (Exception e) {
// We failed to insert into the database. This can happen if
// the SD card is unmounted.
Log.e(TAG, "failed to add video to media store", e);
uri = null;
} finally {
Log.v(TAG, "Current video URI: " + uri);
}
return uri;
}
项目:nexus-gallery
文件:BucketHelper.java
private static BucketEntry[] loadBucketEntriesFromImagesAndVideoTable(
JobContext jc, ContentResolver resolver, int type) {
HashMap<Integer, BucketEntry> buckets = new HashMap<Integer, BucketEntry>(64);
if ((type & MediaObject.MEDIA_TYPE_IMAGE) != 0) {
updateBucketEntriesFromTable(
jc, resolver, Images.Media.EXTERNAL_CONTENT_URI, buckets);
}
if ((type & MediaObject.MEDIA_TYPE_VIDEO) != 0) {
updateBucketEntriesFromTable(
jc, resolver, Video.Media.EXTERNAL_CONTENT_URI, buckets);
}
BucketEntry[] entries = buckets.values().toArray(new BucketEntry[buckets.size()]);
Arrays.sort(entries, new Comparator<BucketEntry>() {
@Override
public int compare(BucketEntry a, BucketEntry b) {
// sorted by dateTaken in descending order
return b.dateTaken - a.dateTaken;
}
});
return entries;
}
项目:nexus-gallery
文件:LocalAlbum.java
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);
}
项目:nexus-gallery
文件:SecureAlbum.java
private void updateExistingItems() {
if (mAllItems.size() == 0) return;
// Query existing ids.
ArrayList<Integer> imageIds = queryExistingIds(
Images.Media.EXTERNAL_CONTENT_URI, mMinImageId, mMaxImageId);
ArrayList<Integer> videoIds = queryExistingIds(
Video.Media.EXTERNAL_CONTENT_URI, mMinVideoId, mMaxVideoId);
// Construct the existing items list.
mExistingItems.clear();
for (int i = mAllItems.size() - 1; i >= 0; i--) {
Path path = mAllItems.get(i);
boolean isVideo = mAllItemTypes.get(i);
int id = Integer.parseInt(path.getSuffix());
if (isVideo) {
if (videoIds.contains(id)) mExistingItems.add(path);
} else {
if (imageIds.contains(id)) mExistingItems.add(path);
}
}
}
项目:nexus-gallery
文件:LocalVideo.java
public LocalVideo(Path path, GalleryApp context, int id) {
super(path, nextVersionNumber());
mApplication = context;
ContentResolver resolver = mApplication.getContentResolver();
Uri uri = Video.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = LocalAlbum.getItemCursor(resolver, uri, PROJECTION, id);
if (cursor == null) {
throw new RuntimeException("cannot get cursor for: " + path);
}
try {
if (cursor.moveToNext()) {
loadFromCursor(cursor);
} else {
throw new RuntimeException("cannot find data for: " + path);
}
} finally {
cursor.close();
}
}
项目:client-android
文件:PBJournalAdapter.java
@Override
public boolean handleMessage(Message message) {
// done on async thread
final View view = (View) message.obj;
final ImageView thumbImageView = (ImageView) view.findViewById(R.id.thumbnail);
Bitmap bitmap = Images.Thumbnails.getThumbnail(context.getContentResolver(),
message.what, Images.Thumbnails.MICRO_KIND, null);
if (bitmap == null) {
bitmap = Video.Thumbnails.getThumbnail(context.getContentResolver(),
message.what, Video.Thumbnails.MICRO_KIND, null);
}
final Bitmap fBitmap = bitmap;
// back on UI thread to set the bitmap to the view
new Handler(context.getMainLooper()).post(new Runnable() {
@Override
public void run() {
thumbImageView.setImageBitmap(fBitmap);
}
});
return true;
}
项目:nexus-camera
文件:VideoModule.java
private void generateVideoFilename(int outputFileFormat) {
long dateTaken = System.currentTimeMillis();
String title = createName(dateTaken);
// Used when emailing.
String filename = title + convertOutputFormatToFileExt(outputFileFormat);
String mime = convertOutputFormatToMimeType(outputFileFormat);
String path = Storage.DIRECTORY + '/' + filename;
String tmpPath = path + ".tmp";
mCurrentVideoValues = new ContentValues(9);
mCurrentVideoValues.put(Video.Media.TITLE, title);
mCurrentVideoValues.put(Video.Media.DISPLAY_NAME, filename);
mCurrentVideoValues.put(Video.Media.DATE_TAKEN, dateTaken);
mCurrentVideoValues.put(MediaColumns.DATE_MODIFIED, dateTaken / 1000);
mCurrentVideoValues.put(Video.Media.MIME_TYPE, mime);
mCurrentVideoValues.put(Video.Media.DATA, path);
mCurrentVideoValues.put(Video.Media.RESOLUTION,
Integer.toString(mProfile.videoFrameWidth) + "x" +
Integer.toString(mProfile.videoFrameHeight));
Location loc = mLocationManager.getCurrentLocation();
if (loc != null) {
mCurrentVideoValues.put(Video.Media.LATITUDE, loc.getLatitude());
mCurrentVideoValues.put(Video.Media.LONGITUDE, loc.getLongitude());
}
mVideoFilename = tmpPath;
Log.v(TAG, "New video filename: " + mVideoFilename);
}
项目:FFmpegRecorder
文件:Util.java
public static String createFinalPath(Context context)
{
long dateTaken = System.currentTimeMillis();
String title = CONSTANTS.FILE_START_NAME + dateTaken;
String filename = title + CONSTANTS.VIDEO_EXTENSION;
String filePath = genrateFilePath(context,String.valueOf(dateTaken), true, null);
ContentValues values = new ContentValues(7);
values.put(Video.Media.TITLE, title);
values.put(Video.Media.DISPLAY_NAME, filename);
values.put(Video.Media.DATE_TAKEN, dateTaken);
values.put(Video.Media.MIME_TYPE, "video/3gpp");
values.put(Video.Media.DATA, filePath);
videoContentValues = values;
return filePath;
}
项目:WoTu
文件:LocalVideo.java
public LocalVideo(Path path, WoTuApp context, long id) {
super(path, nextVersionNumber());
mApplication = context;
ContentResolver resolver = mApplication.getContentResolver();
Uri uri = Video.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = LocalAlbum.getItemCursor(resolver, uri, PROJECTION, id);
if (cursor == null) {
throw new RuntimeException("cannot get cursor for: " + path);
}
try {
if (cursor.moveToNext()) {
loadFromCursor(cursor);
} else {
throw new RuntimeException("cannot find data for: " + path);
}
} finally {
cursor.close();
}
}
项目:Launchpet2
文件:BitmapManager.java
public synchronized void cancelThreadDecoding(Thread t, ContentResolver cr) {
ThreadStatus status = getOrCreateThreadStatus(t);
status.mState = State.CANCEL;
if (status.mOptions != null) {
status.mOptions.requestCancelDecode();
}
// Wake up threads in waiting list
notifyAll();
// Since our cancel request can arrive MediaProvider earlier than getThumbnail request,
// we use mThumbRequesting flag to make sure our request does cancel the request.
try {
synchronized (status) {
while (status.mThumbRequesting) {
Images.Thumbnails.cancelThumbnailRequest(cr, -1, t.getId());
Video.Thumbnails.cancelThumbnailRequest(cr, -1, t.getId());
status.wait(200);
}
}
} catch (InterruptedException ex) {
// ignore it.
}
}
项目:AndroidMedia
文件:VideoCamera.java
private void createVideoPath() {
long dateTaken = System.currentTimeMillis();
String title = createName(dateTaken);
String filename = title + ".3gp"; // Used when emailing.
String cameraDirPath = ImageManager.CAMERA_IMAGE_BUCKET_NAME;
String filePath = cameraDirPath + "/" + filename;
File cameraDir = new File(cameraDirPath);
cameraDir.mkdirs();
ContentValues values = new ContentValues(7);
values.put(Video.Media.TITLE, title);
values.put(Video.Media.DISPLAY_NAME, filename);
values.put(Video.Media.DATE_TAKEN, dateTaken);
values.put(Video.Media.MIME_TYPE, "video/3gpp");
values.put(Video.Media.DATA, filePath);
mVideoFilename = filePath;
Log.v(TAG, "Current camera video filename: " + mVideoFilename);
mCurrentVideoValues = values;
}
项目:AndroidMedia
文件:VideoCamera.java
private void registerVideo() {
if (mVideoFileDescriptor == null) {
Uri videoTable = Uri.parse("content://media/external/video/media");
mCurrentVideoValues.put(Video.Media.SIZE,
new File(mCurrentVideoFilename).length());
try {
mCurrentVideoUri = mContentResolver.insert(videoTable,
mCurrentVideoValues);
} catch (Exception e) {
// We failed to insert into the database. This can happen if
// the SD card is unmounted.
mCurrentVideoUri = null;
mCurrentVideoFilename = null;
} finally {
Log.v(TAG, "Current video URI: " + mCurrentVideoUri);
}
}
mCurrentVideoValues = null;
}
项目:AndroidMedia
文件:BitmapManager.java
/**
* Gets the thumbnail of the given ID of the original image.
*
* <p> This method wraps around @{code getThumbnail} in {@code
* android.provider.MediaStore}. It provides the ability to cancel it.
*/
public Bitmap getThumbnail(ContentResolver cr, long origId, int kind,
BitmapFactory.Options options, boolean isVideo) {
Thread t = Thread.currentThread();
ThreadStatus status = getOrCreateThreadStatus(t);
if (!canThreadDecoding(t)) {
Log.d(TAG, "Thread " + t + " is not allowed to decode.");
return null;
}
try {
if (isVideo) {
return Video.Thumbnails.getThumbnail(cr, origId, t.getId(),
kind, null);
} else {
return Images.Thumbnails.getThumbnail(cr, origId, t.getId(),
kind, null);
}
} finally {
synchronized (status) {
status.notifyAll();
}
}
}
项目:AndroidMedia
文件:Util.java
public static String createFinalPath(Context context) {
long dateTaken = System.currentTimeMillis();
String title = CONSTANTS.FILE_START_NAME + dateTaken;
String filename = title + CONSTANTS.VIDEO_EXTENSION;
String filePath = genrateFilePath(context, String.valueOf(dateTaken), true, null);
ContentValues values = new ContentValues(7);
values.put(Video.Media.TITLE, title);
values.put(Video.Media.DISPLAY_NAME, filename);
values.put(Video.Media.DATE_TAKEN, dateTaken);
values.put(Video.Media.MIME_TYPE, "video/3gpp");
values.put(Video.Media.DATA, filePath);
videoContentValues = values;
return filePath;
}
项目:AndroidMedia
文件:CamcorderActivity.java
private void createVideoPath() {
long dateTaken = System.currentTimeMillis();
String title = createName(dateTaken);
String filename = title + ".3gp"; // Used when emailing.
String cameraDirPath = ImageManager.CAMERA_IMAGE_BUCKET_NAME;
String filePath = cameraDirPath + "/" + filename;
File cameraDir = new File(cameraDirPath);
cameraDir.mkdirs();
ContentValues values = new ContentValues(7);
values.put(Video.Media.TITLE, title);
values.put(Video.Media.DISPLAY_NAME, filename);
values.put(Video.Media.DATE_TAKEN, dateTaken);
values.put(Video.Media.MIME_TYPE, "video/3gpp");
values.put(Video.Media.DATA, filePath);
mVideoFilename = filePath;
Log.v(TAG, "Current camera video filename: " + mVideoFilename);
mCurrentVideoValues = values;
}
项目:AndroidMedia
文件:CamcorderActivity.java
private void registerVideo() {
if (mVideoFileDescriptor == null) {
Uri videoTable = Uri.parse("content://media/external/video/media");
mCurrentVideoValues.put(Video.Media.SIZE,
new File(mCurrentVideoFilename).length());
try {
mCurrentVideoUri = mContentResolver.insert(videoTable,
mCurrentVideoValues);
} catch (Exception e) {
// We failed to insert into the database. This can happen if
// the SD card is unmounted.
mCurrentVideoUri = null;
mCurrentVideoFilename = null;
} finally {
Log.v(TAG, "Current video URI: " + mCurrentVideoUri);
}
}
mCurrentVideoValues = null;
}
项目:AndroidMedia
文件:CamcorderActivity.java
private void showAlert() {
// fadeOut(findViewById(R.id.shutter_button));
if (mCurrentVideoFilename != null) {
Bitmap src = ThumbnailUtils.createVideoThumbnail(
mCurrentVideoFilename, Video.Thumbnails.MINI_KIND);
// MetadataRetriever already rotates the thumbnail. We should rotate
// it back (and mirror if it is front-facing camera).
CameraInfo[] info = CameraHolder.instance().getCameraInfo();
if (info[mCameraId].facing == CameraInfo.CAMERA_FACING_BACK) {
src = Util.rotateAndMirror(src, -mOrientationHint, false);
} else {
src = Util.rotateAndMirror(src, -mOrientationHint, true);
}
mVideoFrame.setImageBitmap(src);
mVideoFrame.setVisibility(View.VISIBLE);
}
// int[] pickIds = {R.id.btn_retake, R.id.btn_done, R.id.btn_play};
// for (int id : pickIds) {
// View button = findViewById(id);
// fadeIn(((View) button.getParent()));
// }
}
项目:persontracker
文件:ARDroneMediaGallery.java
public void deleteVideos(int[] ids)
{
Uri uri = FileUtils.isExtStorgAvailable() ? Video.Media.EXTERNAL_CONTENT_URI
: Video.Media.INTERNAL_CONTENT_URI;
String where = "";
int size = ids.length;
String[] args = new String[size];
for (int i=0; i<ids.length; ++i) {
args[i] = String.valueOf(ids[i]);
where += Video.Media._ID + "=?";
if (i<size-1) {
where += " OR ";
}
}
contentResolver.delete(uri, where, args);
}
项目:sagesmobile-mCollect
文件:VideoWidget.java
private String getPathFromUri(Uri uri) {
if (uri.toString().startsWith("file")) {
return uri.toString().substring(6);
} else {
String[] videoProjection = { Video.Media.DATA };
Cursor c = null;
try {
c = getContext().getContentResolver().query(uri,
videoProjection, null, null, null);
int column_index = c.getColumnIndexOrThrow(Video.Media.DATA);
String videoPath = null;
if (c.getCount() > 0) {
c.moveToFirst();
videoPath = c.getString(column_index);
}
return videoPath;
} finally {
if (c != null) {
c.close();
}
}
}
}
项目:sagesmobile-mCollect
文件:MediaUtils.java
public static final Uri getVideoUriFromMediaProvider(String videoFile) {
String selection = Video.VideoColumns.DATA + "=?";
String[] selectArgs = { videoFile };
String[] projection = { Video.VideoColumns._ID };
Cursor c = null;
try {
c = Collect.getInstance().getContentResolver().query(
android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
projection, selection, selectArgs, null);
if (c.getCount() > 0) {
c.moveToFirst();
String id = c.getString(c.getColumnIndex(Video.VideoColumns._ID));
return Uri.withAppendedPath(
android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI, id);
}
return null;
} finally {
if ( c != null ) {
c.close();
}
}
}
项目:flickr-uploader
文件:UploadService.java
@Override
public void onCreate() {
super.onCreate();
instance = this;
LOG.debug("Service created…");
running = true;
getContentResolver().registerContentObserver(Images.Media.EXTERNAL_CONTENT_URI, true, imageTableObserver);
getContentResolver().registerContentObserver(Video.Media.EXTERNAL_CONTENT_URI, true, imageTableObserver);
if (thread == null || !thread.isAlive()) {
thread = new Thread(new UploadRunnable());
thread.start();
}
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(batteryReceiver, filter);
checkNewFiles();
Notifications.init();
}
项目:easyfilemanager
文件: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;
}
项目:easyfilemanager
文件:MediaDocumentsProvider.java
private Uri getUriForDocumentId(String docId) {
final Ident ident = getIdentForDocId(docId);
if (TYPE_IMAGE.equals(ident.type) && ident.id != -1) {
return ContentUris.withAppendedId(
Images.Media.EXTERNAL_CONTENT_URI, ident.id);
} else if (TYPE_VIDEO.equals(ident.type) && ident.id != -1) {
return ContentUris.withAppendedId(
Video.Media.EXTERNAL_CONTENT_URI, ident.id);
} else if (TYPE_AUDIO.equals(ident.type) && ident.id != -1) {
return ContentUris.withAppendedId(
Audio.Media.EXTERNAL_CONTENT_URI, ident.id);
} else {
throw new UnsupportedOperationException("Unsupported document " + docId);
}
}