public abstract class MediaItem extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
MediaItem.GetThumbnailListCallback |
Modifier and Type | Field and Description |
---|---|
static int |
END_OF_FILE
A constant which can be used to specify the end of the file (instead of
providing the actual duration of the media item).
|
protected Transition |
mBeginTransition
Beginning and end transitions
|
protected Transition |
mEndTransition |
protected String |
mFilename
The name of the file associated with the MediaItem
|
protected String |
mGeneratedImageClip |
protected boolean |
mRegenerateClip |
static int |
RENDERING_MODE_BLACK_BORDER
When using the RENDERING_MODE_BLACK_BORDER rendering mode video frames
are resized by preserving the aspect ratio until the movie matches one of
the dimensions of the output movie.
|
static int |
RENDERING_MODE_CROPPING
When using the RENDERING_MODE_CROPPING rendering mode video frames are
scaled horizontally or vertically by preserving the original aspect ratio
of the media item.
|
static int |
RENDERING_MODE_STRETCH
When using the RENDERING_MODE_STRETCH rendering mode video frames are
stretched horizontally or vertically to match the current aspect ratio of
the video editor.
|
Modifier | Constructor and Description |
---|---|
protected |
MediaItem(VideoEditor editor,
String mediaItemId,
String filename,
int renderingMode)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addEffect(Effect effect)
Add the specified effect to this media item.
|
void |
addOverlay(Overlay overlay)
Add an overlay to the storyboard.
|
protected void |
adjustTransitions()
Adjust the duration transitions.
|
boolean |
equals(Object object)
Compares this instance with the specified object and indicates if they
are equal.
|
List<Effect> |
getAllEffects()
Get the list of effects.
|
List<Overlay> |
getAllOverlays()
Get the list of overlays associated with this media item
Note that if any overlay source files are not accessible anymore,
this method will still provide the full list of overlays.
|
abstract int |
getAspectRatio()
Get aspect ratio of the source media item.
|
Transition |
getBeginTransition() |
abstract long |
getDuration() |
Effect |
getEffect(String effectId)
Find the effect with the specified id
|
Transition |
getEndTransition() |
String |
getFilename() |
abstract int |
getFileType() |
abstract int |
getHeight() |
String |
getId() |
Overlay |
getOverlay(String overlayId)
Find the overlay with the specified id
|
int |
getRenderingMode() |
abstract Bitmap |
getThumbnail(int width,
int height,
long timeMs)
Create a thumbnail at specified time in a video stream in Bitmap format
|
Bitmap[] |
getThumbnailList(int width,
int height,
long startMs,
long endMs,
int thumbnailCount) |
abstract void |
getThumbnailList(int width,
int height,
long startMs,
long endMs,
int thumbnailCount,
int[] indices,
MediaItem.GetThumbnailListCallback callback)
Get the array of Bitmap thumbnails between start and end.
|
abstract long |
getTimelineDuration() |
abstract int |
getWidth() |
int |
hashCode()
Returns an integer hash code for this object.
|
protected boolean |
isOverlapping(long startTimeMs1,
long durationMs1,
long startTimeMs2,
long durationMs2)
Check if two items overlap in time
|
Effect |
removeEffect(String effectId)
Remove the effect with the specified id.
|
Overlay |
removeOverlay(String overlayId)
Remove the overlay with the specified id.
|
void |
setRenderingMode(int renderingMode)
If aspect ratio of the MediaItem is different from the aspect ratio of
the editor then this API controls the rendering mode.
|
public static final int END_OF_FILE
public static final int RENDERING_MODE_BLACK_BORDER
public static final int RENDERING_MODE_STRETCH
public static final int RENDERING_MODE_CROPPING
protected final String mFilename
protected Transition mBeginTransition
protected Transition mEndTransition
protected String mGeneratedImageClip
protected boolean mRegenerateClip
protected MediaItem(VideoEditor editor, String mediaItemId, String filename, int renderingMode) throws IOException
editor
- The video editor referencemediaItemId
- The MediaItem idfilename
- name of the media file.renderingMode
- The rendering modeIOException
- if file is not foundIllegalArgumentException
- if a capability such as file format is
not supported the exception object contains the unsupported
capabilitypublic String getId()
public String getFilename()
public void setRenderingMode(int renderingMode)
renderingMode
- rendering mode. It is one of:
RENDERING_MODE_BLACK_BORDER
,
RENDERING_MODE_STRETCH
public int getRenderingMode()
public Transition getBeginTransition()
public Transition getEndTransition()
public abstract long getTimelineDuration()
public abstract long getDuration()
public abstract int getFileType()
public abstract int getWidth()
public abstract int getHeight()
public abstract int getAspectRatio()
public void addEffect(Effect effect)
effect
- The effect to applyIllegalStateException
- if a preview or an export is in progressIllegalArgumentException
- if the effect start and/or duration are
invalid or if the effect cannot be applied to this type of media
item or if the effect id is not unique across all the Effects
added.public Effect removeEffect(String effectId)
effectId
- The id of the effect to be removedIllegalStateException
- if a preview or an export is in progresspublic Effect getEffect(String effectId)
effectId
- The effect idpublic List<Effect> getAllEffects()
public void addOverlay(Overlay overlay) throws FileNotFoundException, IOException
overlay
- The overlay to addIllegalStateException
- if a preview or an export is in progress or
if the overlay id is not unique across all the overlays added
or if the bitmap is not specified or if the dimensions of the
bitmap do not match the dimensions of the media itemFileNotFoundException,
- IOException if overlay could not be saved
to project pathFileNotFoundException
IOException
public Overlay removeOverlay(String overlayId)
overlayId
- The id of the overlay to be removedIllegalStateException
- if a preview or an export is in progresspublic Overlay getOverlay(String overlayId)
overlayId
- The overlay idpublic List<Overlay> getAllOverlays()
public abstract Bitmap getThumbnail(int width, int height, long timeMs) throws IOException
width
- width of the thumbnail in pixelsheight
- height of the thumbnail in pixelstimeMs
- The time in the source video file at which the thumbnail is
requested (even if trimmed).IOException
- if a file error occursIllegalArgumentException
- if time is out of video durationpublic abstract void getThumbnailList(int width, int height, long startMs, long endMs, int thumbnailCount, int[] indices, MediaItem.GetThumbnailListCallback callback) throws IOException
width
- width of the thumbnail in pixelsheight
- height of the thumbnail in pixelsstartMs
- The start of time range in millisecondsendMs
- The end of the time range in millisecondsthumbnailCount
- The thumbnail countindices
- The indices of the thumbnails wantedcallback
- The callback used to pass back the bitmapsIOException
- if a file error occurspublic Bitmap[] getThumbnailList(int width, int height, long startMs, long endMs, int thumbnailCount) throws IOException
IOException
public boolean equals(Object object)
Object
o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and Object.hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
equals
in class Object
object
- the object to compare this instance with.true
if the specified object is equal to this Object
; false
otherwise.Object.hashCode()
public int hashCode()
Object
Object.equals(java.lang.Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)
protected boolean isOverlapping(long startTimeMs1, long durationMs1, long startTimeMs2, long durationMs2)
startTimeMs1
- Item 1 start timedurationMs1
- Item 1 durationstartTimeMs2
- Item 2 start timedurationMs2
- Item 2 end timeprotected void adjustTransitions()