5555import java .util .List ;
5656import java .util .Locale ;
5757
58+
5859public class Camera2Recorder extends AbstractCamera2Recorder implements HostDevicePhotoRecorder , HostDeviceStreamRecorder {
5960
6061 /**
@@ -532,18 +533,15 @@ private void registerVideo(final File videoFile) {
532533 values .put (MediaStore .Video .Media .ARTIST , "DeviceConnect" );
533534 values .put (MediaStore .Video .Media .MIME_TYPE , "video/avc" );
534535 values .put (MediaStore .Video .Media .DATA , videoFile .toString ());
535- long thumbnailId = registerVideoThumbnail (videoFile );
536- if (thumbnailId > -1 ) {
537- values .put (MediaStore .Video .Media .MINI_THUMB_MAGIC , thumbnailId );
538- }
539536 Uri uri = resolver .insert (MediaStore .Video .Media .EXTERNAL_CONTENT_URI , values );
540537
541538 // 動画IDをサムネイルDBに挿入.
542539 try {
543- if (uri != null && thumbnailId > - 1 ) {
540+ if (uri != null ) {
544541 String id = uri .getLastPathSegment ();
545542 if (id != null ) {
546543 long videoId = Long .parseLong (id );
544+ long thumbnailId = registerVideoThumbnail (videoFile , videoId );
547545 boolean updated = updateThumbnailInfo (thumbnailId , videoId );
548546 if (updated ) {
549547 if (DEBUG ) {
@@ -569,7 +567,7 @@ private void registerVideo(final File videoFile) {
569567 }
570568 }
571569
572- private long registerVideoThumbnail (final File videoFile ) {
570+ private long registerVideoThumbnail (final File videoFile , final long videoId ) {
573571 String videoFilePath = videoFile .getAbsolutePath ();
574572 final int kind = MediaStore .Images .Thumbnails .MINI_KIND ;
575573 Bitmap thumbnail = ThumbnailUtils .createVideoThumbnail (videoFilePath , kind );
@@ -588,6 +586,7 @@ private long registerVideoThumbnail(final File videoFile) {
588586 values .put (MediaStore .Video .Thumbnails .WIDTH , thumbnail .getWidth ());
589587 values .put (MediaStore .Video .Thumbnails .HEIGHT , thumbnail .getHeight ());
590588 values .put (MediaStore .Video .Thumbnails .KIND , kind );
589+ values .put (MediaStore .Video .Thumbnails .VIDEO_ID , videoId );
591590 ContentResolver resolver = getContext ().getApplicationContext ().getContentResolver ();
592591 Uri uri = resolver .insert (MediaStore .Video .Thumbnails .EXTERNAL_CONTENT_URI , values );
593592 if (uri == null ) {
@@ -617,11 +616,6 @@ private long registerVideoThumbnail(final File videoFile) {
617616 Log .e (TAG , "Failed to parse thumbnail ID as long type: videoFilePath=" + videoFilePath );
618617 }
619618 return -1 ;
620- } catch (NullPointerException e ) {
621- if (DEBUG ) {
622- Log .e (TAG , "Failed to parse thumbnail ID as long type: videoFilePath=" + videoFilePath );
623- }
624- return -1 ;
625619 } finally {
626620 thumbnail .recycle ();
627621 }
0 commit comments