1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.media.videoeditor; 18 19/** 20 * This class allows to create sliding transitions 21 * {@hide} 22 */ 23public class TransitionSliding extends Transition { 24 25 /** Video 1 is pushed to the right while video 2 is coming from left */ 26 public final static int DIRECTION_RIGHT_OUT_LEFT_IN = 0; 27 /** Video 1 is pushed to the left while video 2 is coming from right */ 28 public static final int DIRECTION_LEFT_OUT_RIGHT_IN = 1; 29 /** Video 1 is pushed to the top while video 2 is coming from bottom */ 30 public static final int DIRECTION_TOP_OUT_BOTTOM_IN = 2; 31 /** Video 1 is pushed to the bottom while video 2 is coming from top */ 32 public static final int DIRECTION_BOTTOM_OUT_TOP_IN = 3; 33 34 // The sliding transitions 35 private final int mSlidingDirection; 36 37 /** 38 * An object of this type cannot be instantiated by using the default 39 * constructor 40 */ 41 @SuppressWarnings("unused") 42 private TransitionSliding() { 43 this(null, null, null, 0, 0, 0); 44 } 45 46 /** 47 * Constructor 48 * 49 * @param transitionId The transition id 50 * @param afterMediaItem The transition is applied to the end of this 51 * media item 52 * @param beforeMediaItem The transition is applied to the beginning of 53 * this media item 54 * @param durationMs duration of the transition in milliseconds 55 * @param behavior behavior is one of the behavior defined in Transition 56 * class 57 * @param direction direction shall be one of the supported directions like 58 * RIGHT_OUT_LEFT_IN 59 * 60 * @throws IllegalArgumentException if behavior is not supported. 61 */ 62 public TransitionSliding(String transitionId, MediaItem afterMediaItem, 63 MediaItem beforeMediaItem, long durationMs, int behavior, 64 int direction) { 65 super(transitionId, afterMediaItem, beforeMediaItem, durationMs, behavior); 66 switch (direction) { 67 case DIRECTION_RIGHT_OUT_LEFT_IN: 68 case DIRECTION_LEFT_OUT_RIGHT_IN: 69 case DIRECTION_TOP_OUT_BOTTOM_IN: 70 case DIRECTION_BOTTOM_OUT_TOP_IN: 71 break; 72 73 default: 74 throw new IllegalArgumentException("Invalid direction"); 75 } 76 mSlidingDirection = direction; 77 } 78 79 /** 80 * Get the sliding direction. 81 * 82 * @return The sliding direction 83 */ 84 public int getDirection() { 85 return mSlidingDirection; 86 } 87 88 /* 89 * {@inheritDoc} 90 */ 91 @Override 92 void generate() { 93 super.generate(); 94 } 95} 96