danger.app
Class VideoRecord

java.lang.Object
  extended by danger.app.GalleryItem
      extended by danger.app.VideoRecord


public class VideoRecord
extends GalleryItem

VideoRecord are wrappers for videos that are stored in the Camera gallery.

Unlike PhotoRecords, VideoRecord objects do NOT get synced to the service; they are strictly filesystem-only.

VideoRecords should not be (and cannot be) constructed manually;

GalleryItem.createImportableGalleryItem(byte[], java.lang.String) will create objects for you, and GalleryItemIPCPayload will return fully-formed objects.

Since:
4.5

Field Summary
 
Fields inherited from class danger.app.GalleryItem
ANY_HEIGHT, ANY_WIDTH, DESTINATION_DEVICE_GALLERY, DESTINATION_MEMORY_CARD_CUSTOM_PATH, DESTINATION_MEMORY_CARD_DCIM, IMPORT_RESULT_MEMORY_CARD, IMPORT_RESULT_PHOTOS, IMPORT_RESULT_PLURAL, IMPORT_RESULT_SUCCESS, IMPORT_RESULT_VIDEOS, TYPE_IMAGE, TYPE_VIDEO
 
Method Summary
 void dumpRecord()
          Debugging method used to dump the contents of this record.
 boolean equals(Object obj)
          Compares two VideoRecords for equivalence based on whether or not their file pathnames match.
 Bitmap getBitmap(int width, int height)
          Returns a bitmap representing a thumbnail of this video.
 byte[] getData()
          Returns the raw video data in the form of a byte array.
 int getDataSize()
          Returns the size of the raw data contained in this VideoRecord.
 Date getDateCreated()
          Returns a Date representing when this VideoRecord was created.
 Video getDecodedVideo()
          Returns a loaded and initialized Video object for this record.
 int getEncodedType()
          Returns the raw enumerated data type of the video file (3GP, MP4, etc.).
 File getFile()
          Returns the file associated with this VideoRecord.
 String getFilesystemPath()
          Returns the filesystem path of this VideoRecord.
 int getHeight()
          Returns the height, in pixels, of the video.
 int getMediaType()
          Returns the type of this VideoRecord object.
 String getMimeType()
          Returns the MIME type of this GalleryItem object.
 String getName()
          Returns the filename of the video.
 int getWidth()
          Returns the width, in pixels, of the video.
 boolean hasFile()
          Returns whether or not this VideoRecord points to a file.
 int hashCode()
          Returns a hash code for this VideoRecord.
 boolean isImage()
          Returns whether or not this GalleryItem is an image.
 boolean isValidVideo()
          Returns whether or not the video is valid.
 boolean isVideo()
          Returns whether or not this GalleryItem is a video.
 boolean play()
          Convenience method for playing the current VideoRecord within a PreviewWindow.
 boolean rename(String name)
          Sets the filename of the video.
 
Methods inherited from class danger.app.GalleryItem
addObserver, createImportableGalleryItem, importGalleryItem, importGalleryItem, removeObserver
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMediaType

public final int getMediaType()
Returns the type of this VideoRecord object.

Specified by:
getMediaType in class GalleryItem
Returns:
GalleryItem.TYPE_VIDEO.
Since:
4.5

isVideo

public boolean isVideo()
Returns whether or not this GalleryItem is a video.

Specified by:
isVideo in class GalleryItem
Returns:
true
Since:
4.5
See Also:
GalleryItem

isImage

public boolean isImage()
Returns whether or not this GalleryItem is an image.

Specified by:
isImage in class GalleryItem
Returns:
false
Since:
4.5
See Also:
GalleryItem

equals

public boolean equals(Object obj)
Compares two VideoRecords for equivalence based on whether or not their file pathnames match.

If either VideoRecord is an internal device gallery object, this will instead perform a standard equals() based on object equivalence.

Overrides:
equals in class Object
Parameters:
obj - Object for equivalence test
Returns:
boolean Indicates if objects are equivalent.

hashCode

public int hashCode()
Returns a hash code for this VideoRecord.

Overrides:
hashCode in class Object
Returns:
int representing the object's hash code
See Also:
Object.hashCode()

getDateCreated

public final Date getDateCreated()
Returns a Date representing when this VideoRecord was created. (Normally this would represent when the video itself was captured)

Specified by:
getDateCreated in class GalleryItem
Returns:
Date representing when video was created and/or captured

getWidth

public final int getWidth()
Returns the width, in pixels, of the video.

Specified by:
getWidth in class GalleryItem
Returns:
Width of the video, or 0 if the video is invalid.

getHeight

public final int getHeight()
Returns the height, in pixels, of the video.

Specified by:
getHeight in class GalleryItem
Returns:
Height of the video, or 0 if the video is invalid.

getFile

public final File getFile()
Returns the file associated with this VideoRecord.

Overrides:
getFile in class GalleryItem
Returns:
Video File object, or null if this is an import object.

getName

public final String getName()
Returns the filename of the video.

Specified by:
getName in class GalleryItem
Returns:
Filename of the video.

rename

public final boolean rename(String name)
Sets the filename of the video.

Specified by:
rename in class GalleryItem
Parameters:
name - New name to assign to this video.
Returns:
boolean true if successful, false if not.

getFilesystemPath

public final String getFilesystemPath()
Returns the filesystem path of this VideoRecord.

Overrides:
getFilesystemPath in class GalleryItem
Returns:
String representation of path in filesystem where this record is stored.

hasFile

public boolean hasFile()
Returns whether or not this VideoRecord points to a file.

Specified by:
hasFile in class GalleryItem
Returns:
The file pointed to by this VideoRecord, or null if this is an import object

getEncodedType

public final int getEncodedType()
Returns the raw enumerated data type of the video file (3GP, MP4, etc.). The returned types correspond to those found in VideoManager.FileType.

Specified by:
getEncodedType in class GalleryItem
Returns:
Raw data type.
See Also:
VideoManager.FileType

getMimeType

public String getMimeType()
Returns the MIME type of this GalleryItem object.

Specified by:
getMimeType in class GalleryItem
Returns:
MIME type string

getDataSize

public final int getDataSize()
Returns the size of the raw data contained in this VideoRecord.

Specified by:
getDataSize in class GalleryItem
Returns:
Raw data size.

getData

public final byte[] getData()
Returns the raw video data in the form of a byte array. This returns a copy of the raw data; callers are thus responsible for managing its contents.

Specified by:
getData in class GalleryItem
Returns:
Copy of raw data.

getBitmap

public final Bitmap getBitmap(int width,
                              int height)
Returns a bitmap representing a thumbnail of this video.

The returned bitmap will maximize itself within the requested space as much as possible while still maintaining the proper aspect ratio.

Passing in either GalleryItem.ANY_WIDTH or GalleryItem.ANY_HEIGHT (but not both) will return an image that is scaled to fit one dimension; for example: getBitmap(ANY_WIDTH, 400) would return a 400-pixel high bitmap with a width that preserves the aspect ratio.

Passing in both GalleryItem.ANY_WIDTH and GalleryItem.ANY_HEIGHT will return an unscaled bitmap at the media's original width and height.

VideoRecords will remember the last requested width and height to prevent reloading the same bitmap more than once.

Specified by:
getBitmap in class GalleryItem
Parameters:
width - Desired width of bitmap, or GalleryItem.ANY_WIDTH.
height - Desired height of bitmap, or GalleryItem.ANY_HEIGHT.
Returns:
Bitmap representing a thumbnail of this video.

getDecodedVideo

public final Video getDecodedVideo()
Returns a loaded and initialized Video object for this record. VideoRecords do NOT manage or cache these loaded video objects.

Returns:
Decoded video.

play

public final boolean play()
Convenience method for playing the current VideoRecord within a PreviewWindow.


isValidVideo

public final boolean isValidVideo()
Returns whether or not the video is valid.

If the video is invalid, it cannot be played, nor can any thumbnail or video information be obtained from it.

Callers should call this function if getWidth() or getHeight() return 0, if thumbnails refuse to load, or if videos refuse to play to check if this was due to an invalid or corrupt video.

This flag is not set automatically; it will only be set upon unsuccessful attempts to get width, height, or thumbnail information.

Returns:
Decoded video.

dumpRecord

public final void dumpRecord()
Debugging method used to dump the contents of this record.