Home | History | Annotate | Download | only in service
      1 /*
      2  * Copyright (C) 2011 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 android.graphics.Bitmap;
     20 import android.media.videoeditor.AudioTrack;
     21 import android.media.videoeditor.MediaItem;
     22 import android.net.Uri;
     23 import android.os.Bundle;
     24 
     25 import java.util.List;
     26 
     27 /**
     28  * Interface for API service listener. This interface declares various callbacks that
     29  * clients might be interested in to handle responses or state change from various API
     30  * service actions. Clients should extend this interface and override interested callbacks.
     31  * See {@link ProjectsCarouselView} for example usage.
     32  */
     33 public class ApiServiceListener {
     34     /**
     35      * The list of projects was loaded
     36      *
     37      * @param projects The array of projects
     38      * @param exception The exception
     39      */
     40     public void onProjectsLoaded(List<VideoEditorProject> projects, Exception exception) {}
     41 
     42     /**
     43      * The project edit state
     44      *
     45      * @param projectPath The project path
     46      * @param projectEdited true if the project is edited
     47      */
     48     public void onProjectEditState(String projectPath, boolean projectEdited) {}
     49 
     50     /**
     51      * A new project was created
     52      *
     53      * @param projectPath The project path
     54      * @param project The VideoEditor project
     55      * @param mediaItems The list of media items
     56      * @param audioTracks The list of audio tracks
     57      * @param exception The exception that occurred
     58      */
     59     public void onVideoEditorCreated(String projectPath, VideoEditorProject project,
     60             List<MediaItem> mediaItems, List<AudioTrack> audioTracks, Exception exception) {}
     61 
     62     /**
     63      * The project was loaded
     64      *
     65      * @param projectPath The project path
     66      * @param project The VideoEditor project
     67      * @param mediaItems The list of media items
     68      * @param audioTracks The list of audio tracks
     69      * @param exception The exception that occurred
     70      */
     71     public void onVideoEditorLoaded(String projectPath, VideoEditorProject project,
     72             List<MediaItem> mediaItems, List<AudioTrack> audioTracks, Exception exception) {}
     73 
     74     /**
     75      * The aspect ratio was set
     76      *
     77      * @param projectPath The project path
     78      * @param aspectRatio The aspect ratio
     79      * @param exception The exception that occurred
     80      */
     81     public void onVideoEditorAspectRatioSet(String projectPath, int aspectRatio, Exception exception) {}
     82 
     83     /**
     84      * The specified theme was applied
     85      *
     86      * @param projectPath The project path
     87      * @param theme The theme
     88      * @param exception The exception that occurred
     89      */
     90     public void onVideoEditorThemeApplied(String projectPath, String theme, Exception exception) {}
     91 
     92     /**
     93      * Generate preview progress status
     94      *
     95      * @param projectPath The project path
     96      * @param className The class name
     97      * @param itemId The storyboard item id
     98      * @param action The action taken on the item
     99      * @param progress The export progress (0, 100)
    100      */
    101     public void onVideoEditorGeneratePreviewProgress(String projectPath, String className,
    102             String itemId, int action, int progress) {}
    103 
    104     /**
    105      * Export progress status
    106      *
    107      * @param projectPath The project path
    108      * @param filename The name of the file to export
    109      * @param progress The export progress (0, 100)
    110      */
    111     public void onVideoEditorExportProgress(String projectPath, String filename, int progress) {}
    112 
    113     /**
    114      * Export completed callback
    115      *
    116      * @param projectPath The project path
    117      * @param filename The name of the file to export
    118      * @param exception null if no exception has occurred (export succeeded)
    119      * @param cancelled if the export is cancelled by the user
    120      */
    121     public void onVideoEditorExportComplete(String projectPath, String filename,
    122             Exception exception, boolean cancelled) {}
    123 
    124     /**
    125      * Export canceled callback
    126      *
    127      * @param projectPath The project path
    128      * @param filename The name of the file to export
    129      */
    130     public void onVideoEditorExportCanceled(String projectPath, String filename) {}
    131 
    132     /**
    133      * The VideoEditor state was saved
    134      *
    135      * @param projectPath The project path
    136      * @param exception The exception which occurred (if any)
    137      */
    138     public void onVideoEditorSaved(String projectPath, Exception exception) {}
    139 
    140     /**
    141      * The VideoEditor stated was released
    142      *
    143      * @param projectPath The project path
    144      * @param exception The exception which occurred (if any)
    145      */
    146     public void onVideoEditorReleased(String projectPath, Exception exception) {}
    147 
    148     /**
    149      * The VideoEditor stated was deleted.
    150      *
    151      * @param projectPath The project path
    152      * @param exception The exception which occurred (if any)
    153      */
    154     public void onVideoEditorDeleted(String projectPath, Exception exception) {}
    155 
    156     /**
    157      * A new media item was added
    158      *
    159      * @param projectPath The project path
    160      * @param mediaItemId The id of the media item
    161      * @param mediaItem The newly added media item (null if an error occurred)
    162      * @param afterMediaId The media item id preceding the media item
    163      * @param mediaItemClass The media item class
    164      * @param aspectRatio The aspectRatio
    165      * @param exception The exception which occurred
    166      */
    167     public void onMediaItemAdded(String projectPath, String mediaItemId,
    168             MovieMediaItem mediaItem, String afterMediaId, Class<?> mediaItemClass,
    169             Integer aspectRatio, Exception exception) {}
    170 
    171     /**
    172      * Media load complete
    173      *
    174      * @param projectPath The project path
    175      * @param mediaUri The media URI
    176      * @param mimeType The mime type
    177      * @param filename The filename of the downloaded media item
    178      * @param exception The exception which occurred
    179      */
    180     public void onMediaLoaded(String projectPath, Uri mediaUri, String mimeType,
    181             String filename, Exception exception) {}
    182 
    183     /**
    184      * A media item was moved
    185      *
    186      * @param projectPath The project path
    187      * @param mediaItemId The id of the media item which moved
    188      * @param afterMediaItemId The id of the relative media item id
    189      * @param exception The exception which occurred
    190      */
    191     public void onMediaItemMoved(String projectPath, String mediaItemId,
    192             String afterMediaItemId, Exception exception) {}
    193 
    194     /**
    195      * A media item was removed
    196      *
    197      * @param projectPath The project path
    198      * @param mediaItemId The id of the media item which was removed
    199      * @param transition The transition inserted at the removal position
    200      *          if a theme is in use.
    201      * @param exception The exception which occurred
    202      */
    203     public void onMediaItemRemoved(String projectPath, String mediaItemId,
    204             MovieTransition transition, Exception exception) {}
    205 
    206     /**
    207      * A media item rendering mode was set
    208      *
    209      * @param projectPath The project path
    210      * @param mediaItemId The id of the media item
    211      * @param renderingMode The rendering mode
    212      * @param exception The exception which occurred
    213      */
    214     public void onMediaItemRenderingModeSet(String projectPath, String mediaItemId,
    215             int renderingMode, Exception exception) {}
    216 
    217     /**
    218      * A media item duration was set
    219      *
    220      * @param projectPath The project path
    221      * @param mediaItemId The id of the media item
    222      * @param durationMs The duration of the image media item
    223      * @param exception The exception which occurred
    224      */
    225     public void onMediaItemDurationSet(String projectPath, String mediaItemId,
    226             long durationMs, Exception exception) {}
    227 
    228     /**
    229      * A media item boundaries was set
    230      *
    231      * @param projectPath The project path
    232      * @param mediaItemId The id of the media item
    233      * @param beginBoundaryMs The begin boundary
    234      * @param endBoundaryMs The end boundary
    235      * @param exception The exception which occurred
    236      */
    237     public void onMediaItemBoundariesSet(String projectPath, String mediaItemId,
    238             long beginBoundaryMs, long endBoundaryMs, Exception exception) {}
    239 
    240     /**
    241      * A media item thumbnail was extracted
    242      *
    243      * @param projectPath The project path
    244      * @param mediaItemId The id of the media item
    245      * @param thumbnail The bitmap thumbnail
    246      * @param index The index of the thumbnail
    247      * @param token The token given in the original request
    248      * @param exception The exception which occurred
    249      *
    250      * @return true if the bitmap is used
    251      */
    252     public boolean onMediaItemThumbnail(String projectPath, String mediaItemId,
    253             Bitmap thumbnail, int index, int token, Exception exception) {
    254         return false;
    255     }
    256 
    257     /**
    258      * Extract media item audio waveform progress callback
    259      *
    260      * @param projectPath The project path
    261      * @param mediaItemId The id of the media item
    262      * @param progress The progress (0, 100)
    263      */
    264     public void onMediaItemExtractAudioWaveformProgress(String projectPath,
    265             String mediaItemId, int progress) {}
    266 
    267     /**
    268      * The audio waveform of the specified media item completed
    269      *
    270      * @param projectPath The project path
    271      * @param mediaItemId The id of the MediaItem
    272      * @param exception The exception which occurred
    273      */
    274     public void onMediaItemExtractAudioWaveformComplete(String projectPath,
    275             String mediaItemId, Exception exception) {}
    276 
    277     /**
    278      * A new transition was inserted
    279      *
    280      * @param projectPath The project path
    281      * @param transition The newly added transition
    282      * @param afterMediaId After the media id
    283      * @param exception The exception which occurred
    284      */
    285     public void onTransitionInserted(String projectPath, MovieTransition transition,
    286             String afterMediaId, Exception exception) {}
    287 
    288     /**
    289      * A transition was removed
    290      *
    291      * @param projectPath The project path
    292      * @param transitionId The id of the transition which was removed
    293      * @param exception The exception which occurred
    294      */
    295     public void onTransitionRemoved(String projectPath, String transitionId,
    296             Exception exception) {}
    297 
    298     /**
    299      * A transition duration was changed
    300      *
    301      * @param projectPath The project path
    302      * @param transitionId The id of the transition which was modified
    303      * @param durationMs The duration in milliseconds
    304      * @param exception The exception which occurred
    305      */
    306     public void onTransitionDurationSet(String projectPath, String transitionId,
    307             long durationMs, Exception exception) {}
    308 
    309     /**
    310      * Two transition thumbnails were extracted
    311      *
    312      * @param projectPath The project path
    313      * @param transitionId The id of the transition
    314      * @param thumbnails The thumbnails array
    315      * @param exception The exception which occurred
    316      *
    317      * @return true if the bitmap is used
    318      */
    319     public boolean onTransitionThumbnails(String projectPath, String transitionId,
    320             Bitmap[] thumbnails, Exception exception) {
    321         return false;
    322     }
    323 
    324     /**
    325      * A new overlay was added
    326      *
    327      * @param projectPath The project path
    328      * @param overlay The newly added overlay
    329      * @param mediaItemId The media item id
    330      * @param exception The exception which occurred
    331      */
    332     public void onOverlayAdded(String projectPath, MovieOverlay overlay,
    333             String mediaItemId, Exception exception) {}
    334 
    335     /**
    336      * A overlay was removed
    337      *
    338      * @param projectPath The project path
    339      * @param overlayId The id of the overlay
    340      * @param mediaItemId The media item id
    341      * @param exception The exception which occurred
    342      */
    343     public void onOverlayRemoved(String projectPath, String overlayId,
    344             String mediaItemId, Exception exception) {}
    345 
    346     /**
    347      * The overlay start time was set
    348      *
    349      * @param projectPath The project path
    350      * @param overlayId The id of the overlay
    351      * @param mediaItemId The media item id
    352      * @param startTimeMs The start time in milliseconds
    353      * @param exception The exception which occurred
    354      */
    355     public void onOverlayStartTimeSet(String projectPath, String overlayId,
    356             String mediaItemId, long startTimeMs, Exception exception) {}
    357 
    358     /**
    359      * The overlay duration was set
    360      *
    361      * @param projectPath The project path
    362      * @param overlayId The id of the overlay
    363      * @param mediaItemId The media item id
    364      * @param durationMs The duration in milliseconds
    365      * @param exception The exception which occurred
    366      */
    367     public void onOverlayDurationSet(String projectPath, String overlayId,
    368             String mediaItemId, long durationMs, Exception exception) {}
    369 
    370     /**
    371      * The overlay user attributes were set
    372      *
    373      * @param projectPath The project path
    374      * @param overlayId The id of the overlay
    375      * @param mediaItemId The media item id
    376      * @param userAttributes The user attributes
    377      * @param exception The exception which occurred
    378      */
    379     public void onOverlayUserAttributesSet(String projectPath, String overlayId,
    380             String mediaItemId, Bundle userAttributes, Exception exception) {}
    381 
    382     /**
    383      * A new effect was added
    384      *
    385      * @param projectPath The project path
    386      * @param effect The newly added effect
    387      * @param mediaItemId The media item id
    388      * @param exception The exception which occurred
    389      */
    390     public void onEffectAdded(String projectPath, MovieEffect effect,
    391             String mediaItemId, Exception exception) {}
    392 
    393     /**
    394      * An effect was removed
    395      *
    396      * @param projectPath The project path
    397      * @param effectId The id of the effect which was removed
    398      * @param mediaItemId The media item id
    399      * @param exception The exception which occurred
    400      */
    401     public void onEffectRemoved(String projectPath, String effectId,
    402             String mediaItemId, Exception exception) {}
    403 
    404     /**
    405      * A new audio track was added
    406      *
    407      * @param projectPath The project path
    408      * @param audioTrack The newly added audioTrack
    409      * @param exception The exception which occurred
    410      */
    411     public void onAudioTrackAdded(String projectPath, MovieAudioTrack audioTrack,
    412             Exception exception) {}
    413 
    414     /**
    415      * An audio track was removed
    416      *
    417      * @param projectPath The project path
    418      * @param audioTrackId The id of the audio track
    419      * @param exception The exception which occurred
    420      */
    421     public void onAudioTrackRemoved(String projectPath, String audioTrackId,
    422             Exception exception) {}
    423 
    424     /**
    425      * An audio track boundaries was set
    426      *
    427      * @param projectPath The project path
    428      * @param audioTrackId The id of the audio track
    429      * @param beginBoundaryMs The begin boundary
    430      * @param endBoundaryMs The end boundary
    431      * @param exception The exception which occurred
    432      */
    433     public void onAudioTrackBoundariesSet(String projectPath, String audioTrackId,
    434             long beginBoundaryMs, long endBoundaryMs, Exception exception) {}
    435 
    436     /**
    437      * Extract audio waveform progress callback
    438      *
    439      * @param projectPath The project path
    440      * @param audioTrackId The id of the audio track
    441      * @param progress The progress (0, 100)
    442      */
    443     public void onAudioTrackExtractAudioWaveformProgress(String projectPath,
    444             String audioTrackId, int progress) {}
    445 
    446     /**
    447      * The audio track audio waveform of the specified audio track completed
    448      *
    449      * @param projectPath The project path
    450      * @param audioTrackId The id of the audio track
    451      * @param exception The exception which occurred
    452      */
    453     public void onAudioTrackExtractAudioWaveformComplete(String projectPath,
    454             String audioTrackId, Exception exception) {}
    455 }
    456