diff options
author | Gil Dobjanschi <virgild@google.com> | 2010-09-24 12:07:48 -0700 |
---|---|---|
committer | Gil Dobjanschi <virgild@google.com> | 2010-09-24 14:52:05 -0700 |
commit | 05152ffd67a17491337236621aa5f7ef7c3b51db (patch) | |
tree | 2429aa10f25ea7aa092f81617fd9aa9410d71b56 /media/java/android | |
parent | 7eb805707fc512f1711fbf00eb5eec2472a0bae1 (diff) | |
download | frameworks_base-05152ffd67a17491337236621aa5f7ef7c3b51db.zip frameworks_base-05152ffd67a17491337236621aa5f7ef7c3b51db.tar.gz frameworks_base-05152ffd67a17491337236621aa5f7ef7c3b51db.tar.bz2 |
Adjust the duration of transitions if needed.
Change-Id: I2e5f9431b1f1c25b30e2d144916140365b10021b
Diffstat (limited to 'media/java/android')
4 files changed, 66 insertions, 5 deletions
diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java index db7585a..9c39b20 100755 --- a/media/java/android/media/videoeditor/MediaImageItem.java +++ b/media/java/android/media/videoeditor/MediaImageItem.java @@ -116,10 +116,30 @@ public class MediaImageItem extends MediaItem { }
/**
+ * This method will adjust the duration of bounding transitions if the
+ * current duration of the transactions become greater than the maximum
+ * allowable duration.
+ *
* @param durationMs The duration of the image in the storyboard timeline
*/
public void setDuration(long durationMs) {
mDurationMs = durationMs;
+
+ // Check if the duration of transitions need to be adjusted
+ if (mBeginTransition != null) {
+ final long maxDurationMs = mBeginTransition.getMaximumDuration();
+ if (mBeginTransition.getDuration() > maxDurationMs) {
+ mBeginTransition.setDuration(maxDurationMs);
+ }
+ }
+
+ if (mEndTransition != null) {
+ final long maxDurationMs = mEndTransition.getMaximumDuration();
+ if (mEndTransition.getDuration() > maxDurationMs) {
+ mEndTransition.setDuration(maxDurationMs);
+ }
+ }
+
// TODO: Validate/modify the start and the end time of effects and overlays
}
diff --git a/media/java/android/media/videoeditor/MediaItem.java b/media/java/android/media/videoeditor/MediaItem.java index e7be35d..12fbe54 100755 --- a/media/java/android/media/videoeditor/MediaItem.java +++ b/media/java/android/media/videoeditor/MediaItem.java @@ -90,7 +90,7 @@ public abstract class MediaItem { }
/**
- * @return The of the media item
+ * @return The id of the media item
*/
public String getId() {
return mUniqueId;
diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java index af50b83..afca55c 100755 --- a/media/java/android/media/videoeditor/MediaVideoItem.java +++ b/media/java/android/media/videoeditor/MediaVideoItem.java @@ -245,7 +245,10 @@ public class MediaVideoItem extends MediaItem { }
/**
- * Sets the start and end marks for trimming a video media item
+ * Sets the start and end marks for trimming a video media item.
+ * This method will adjust the duration of bounding transitions if the
+ * current duration of the transactions become greater than the maximum
+ * allowable duration.
*
* @param beginMs Start time in milliseconds. Set to 0 to extract from the
* beginning
@@ -265,18 +268,35 @@ public class MediaVideoItem extends MediaItem { }
if (beginMs != mBeginBoundaryTimeMs) {
- mBeginBoundaryTimeMs = beginMs;
if (mBeginTransition != null) {
mBeginTransition.invalidate();
}
}
- if (endMs == mEndBoundaryTimeMs) {
- mEndBoundaryTimeMs = endMs;
+ if (endMs != mEndBoundaryTimeMs) {
if (mEndTransition != null) {
mEndTransition.invalidate();
}
}
+
+ mBeginBoundaryTimeMs = beginMs;
+ mEndBoundaryTimeMs = endMs;
+
+ // Check if the duration of transitions need to be adjusted
+ if (mBeginTransition != null) {
+ final long maxDurationMs = mBeginTransition.getMaximumDuration();
+ if (mBeginTransition.getDuration() > maxDurationMs) {
+ mBeginTransition.setDuration(maxDurationMs);
+ }
+ }
+
+ if (mEndTransition != null) {
+ final long maxDurationMs = mEndTransition.getMaximumDuration();
+ if (mEndTransition.getDuration() > maxDurationMs) {
+ mEndTransition.setDuration(maxDurationMs);
+ }
+ }
+
// TODO: Validate/modify the start and the end time of effects and overlays
}
diff --git a/media/java/android/media/videoeditor/Transition.java b/media/java/android/media/videoeditor/Transition.java index eb71285..e972aeb 100755 --- a/media/java/android/media/videoeditor/Transition.java +++ b/media/java/android/media/videoeditor/Transition.java @@ -124,7 +124,12 @@ public abstract class Transition { * @param durationMs the duration of the transition in milliseconds
*/
public void setDuration(long durationMs) {
+ if (durationMs > getMaximumDuration()) {
+ throw new IllegalArgumentException("The duration is too large");
+ }
+
mDurationMs = durationMs;
+ invalidate();
}
/**
@@ -135,6 +140,22 @@ public abstract class Transition { }
/**
+ * The duration of a transition cannot be greater than half of the minimum
+ * duration of the bounding media items.
+ *
+ * @return The maximum duration of this transition
+ */
+ public long getMaximumDuration() {
+ if (mAfterMediaItem == null) {
+ return mBeforeMediaItem.getDuration() / 2;
+ } else if (mBeforeMediaItem == null) {
+ return mAfterMediaItem.getDuration() / 2;
+ } else {
+ return (Math.min(mAfterMediaItem.getDuration(), mBeforeMediaItem.getDuration()) / 2);
+ }
+ }
+
+ /**
* @return The behavior
*/
public int getBehavior() {
|