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 17 package com.android.videoeditor.service; 18 19 import com.android.videoeditor.R; 20 21 import android.content.Context; 22 import android.media.videoeditor.Transition; 23 import android.media.videoeditor.TransitionAlpha; 24 import android.media.videoeditor.TransitionCrossfade; 25 import android.media.videoeditor.TransitionFadeBlack; 26 import android.media.videoeditor.TransitionSliding; 27 28 /** 29 * Movie theme description 30 */ 31 public class MovieTheme { 32 // Defined themes 33 public static final String THEME_TRAVEL = "travel"; 34 public static final String THEME_SURFING = "surfing"; 35 public static final String THEME_FILM = "film"; 36 public static final String THEME_ROCKANDROLL = "rockandroll"; 37 38 /** 39 * Get theme by name 40 * 41 * @param context The context 42 * @param theme The theme id 43 * @return The theme 44 */ 45 public static MovieTheme getTheme(Context context, String theme) { 46 if (THEME_TRAVEL.equals(theme)) { 47 return new MovieTheme(THEME_TRAVEL, R.string.theme_name_travel, 48 R.drawable.theme_preview_travel, 0, 49 new MovieTransition(TransitionFadeBlack.class, null, 1500, 50 Transition.BEHAVIOR_SPEED_UP), 51 new MovieTransition(TransitionCrossfade.class, null, 1000, 52 Transition.BEHAVIOR_LINEAR), 53 new MovieTransition(TransitionFadeBlack.class, null, 1500, 54 Transition.BEHAVIOR_SPEED_DOWN), 55 new MovieOverlay(null, 0, 1000, context.getString(R.string.theme_travel_title), 56 context.getString(R.string.theme_travel_subtitle), 57 MovieOverlay.OVERLAY_TYPE_CENTER_1), 58 new MovieAudioTrack(R.raw.theme_travel_audio_track)); 59 } else if (THEME_SURFING.equals(theme)) { 60 return new MovieTheme(THEME_SURFING, R.string.theme_name_surfing, 61 R.drawable.theme_preview_surfing, 0, 62 new MovieTransition(TransitionFadeBlack.class, null, 1500, 63 Transition.BEHAVIOR_SPEED_UP), 64 new MovieTransition(TransitionAlpha.class, null, 1000, 65 Transition.BEHAVIOR_LINEAR, R.raw.mask_diagonal, 50, false), 66 new MovieTransition(TransitionFadeBlack.class, null, 1500, 67 Transition.BEHAVIOR_SPEED_DOWN), 68 new MovieOverlay(null, 0, 1000, 69 context.getString(R.string.theme_surfing_title), 70 context.getString(R.string.theme_surfing_subtitle), 71 MovieOverlay.OVERLAY_TYPE_BOTTOM_1), 72 new MovieAudioTrack(R.raw.theme_surfing_audio_track)); 73 } else if (THEME_FILM.equals(theme)) { 74 return new MovieTheme(THEME_FILM, R.string.theme_name_film, 75 R.drawable.theme_preview_film, 0, 76 new MovieTransition(TransitionFadeBlack.class, null, 1500, 77 Transition.BEHAVIOR_SPEED_UP), 78 new MovieTransition(TransitionCrossfade.class, null, 1000, 79 Transition.BEHAVIOR_LINEAR), 80 new MovieTransition(TransitionFadeBlack.class, null, 1500, 81 Transition.BEHAVIOR_SPEED_DOWN), 82 new MovieOverlay(null, 0, 1000, context.getString(R.string.theme_film_title), 83 context.getString(R.string.theme_film_subtitle), 84 MovieOverlay.OVERLAY_TYPE_BOTTOM_1), 85 new MovieAudioTrack(R.raw.theme_film_audio_track)); 86 } else if (THEME_ROCKANDROLL.equals(theme)) { 87 return new MovieTheme(THEME_ROCKANDROLL, R.string.theme_name_rock_and_roll, 88 R.drawable.theme_preview_rock_and_roll, 0, 89 new MovieTransition(TransitionFadeBlack.class, null, 1500, 90 Transition.BEHAVIOR_SPEED_UP), 91 new MovieTransition(TransitionSliding.class, null, 1000, 92 Transition.BEHAVIOR_LINEAR, 93 TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN), 94 new MovieTransition(TransitionFadeBlack.class, null, 1500, 95 Transition.BEHAVIOR_SPEED_DOWN), 96 new MovieOverlay(null, 0, 1000, context.getString( 97 R.string.theme_rock_and_roll_title), 98 context.getString(R.string.theme_rock_and_roll_subtitle), 99 MovieOverlay.OVERLAY_TYPE_BOTTOM_1), 100 new MovieAudioTrack(R.raw.theme_rockandroll_audio_track)); 101 } else { 102 return null; 103 } 104 } 105 106 // Instance variables 107 private final String mId; 108 private final int mNameResId; 109 private final int mPreviewImageResId; 110 private final int mPreviewMovieResId; 111 private final MovieTransition mBeginTransition; 112 private final MovieTransition mMidTransition; 113 private final MovieTransition mEndTransition; 114 private final MovieOverlay mOverlay; 115 private final MovieAudioTrack mAudioTrack; 116 117 /** 118 * Constructor 119 * 120 * @param id The theme id 121 * @param nameResId The string resource id of the theme name 122 * @param previewImageResId The preview image 123 * @param previewMovieResId The preview movie 124 * @param beginTransition The movie begin transition 125 * @param midTransition Transitions between media items 126 * @param endTransition The movie end transition 127 * @param overlay The title (applied only to the first media item) 128 * @param audioTrack The audio track 129 */ 130 private MovieTheme(String id, int nameResId, int previewImageResId, int previewMovieResId, 131 MovieTransition beginTransition, MovieTransition midTransition, 132 MovieTransition endTransition, MovieOverlay overlay, MovieAudioTrack audioTrack) { 133 mId = id; 134 135 mNameResId = nameResId; 136 mPreviewImageResId = previewImageResId; 137 mPreviewMovieResId = previewMovieResId; 138 139 mBeginTransition = beginTransition; 140 mMidTransition = midTransition; 141 mEndTransition = endTransition; 142 143 mOverlay = overlay; 144 145 mAudioTrack = audioTrack; 146 } 147 148 /** 149 * @return The id 150 */ 151 public String getId() { 152 return mId; 153 } 154 155 /** 156 * @return The name resource id 157 */ 158 public int getNameResId() { 159 return mNameResId; 160 } 161 162 /** 163 * @return The preview image resource id 164 */ 165 public int getPreviewImageResId() { 166 return mPreviewImageResId; 167 } 168 169 /** 170 * @return The preview movie resource id 171 */ 172 public int getPreviewMovieResId() { 173 return mPreviewMovieResId; 174 } 175 176 /** 177 * @return The begin transition 178 */ 179 public MovieTransition getBeginTransition() { 180 return mBeginTransition; 181 } 182 183 /** 184 * @return The mid transition 185 */ 186 public MovieTransition getMidTransition() { 187 return mMidTransition; 188 } 189 190 /** 191 * @return The end transition 192 */ 193 public MovieTransition getEndTransition() { 194 return mEndTransition; 195 } 196 197 /** 198 * @return The overlay 199 */ 200 public MovieOverlay getOverlay() { 201 return mOverlay; 202 } 203 204 /** 205 * @return The audio track 206 */ 207 public MovieAudioTrack getAudioTrack() { 208 return mAudioTrack; 209 } 210 } 211