Search in sources :

Example 26 with MediaItem

use of android.media.videoeditor.MediaItem in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorPreviewTest method testRenderPreviewFrame.

/**
     * To test render Preview Frame
     */
@LargeTest
public void testRenderPreviewFrame() throws Exception {
    final String videoItemFileName1 = INPUT_FILE_PATH + "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
    final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
    final String videoItemFileName3 = INPUT_FILE_PATH + "H264_BP_640x480_30fps_256kbps_1_17.mp4";
    final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
    final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
    final String audioFilename = INPUT_FILE_PATH + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
    OverlayData overlayData1 = new OverlayData();
    previewStart = false;
    previewStop = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(0, 10000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, mediaVideoItem2.getDuration() / 2);
    mVideoEditor.addMediaItem(mediaVideoItem2);
    final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", videoItemFileName3, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 2, mediaVideoItem2.getDuration());
    mVideoEditor.addMediaItem(mediaVideoItem3);
    final MediaImageItem mediaImageItem4 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", imageItemFilename1, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    final MediaImageItem mediaImageItem5 = mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", imageItemFilename2, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
    List<MediaItem> mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 3, mediaList.size());
    mVideoEditor.insertMediaItem(mediaImageItem4, mediaVideoItem2.getId());
    mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 4, mediaList.size());
    assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
    assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
    assertEquals("Media item 4", mediaImageItem4, mediaList.get(2));
    assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3));
    mVideoEditor.insertMediaItem(mediaImageItem5, mediaImageItem4.getId());
    mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 5, mediaList.size());
    assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0));
    assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1));
    assertEquals("Media item 4", mediaImageItem4, mediaList.get(2));
    assertEquals("Media item 5", mediaImageItem5, mediaList.get(3));
    assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
    mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem5.getId());
    mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item List Size", 5, mediaList.size());
    assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0));
    assertEquals("Media item 4", mediaImageItem4, mediaList.get(1));
    assertEquals("Media item 5", mediaImageItem5, mediaList.get(2));
    assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3));
    assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4));
    final TransitionCrossfade transition2And4CrossFade = mVideoEditorHelper.createTCrossFade("transition2And4CrossFade", mediaVideoItem2, mediaImageItem4, 2000, Transition.BEHAVIOR_MIDDLE_FAST);
    mVideoEditor.addTransition(transition2And4CrossFade);
    final TransitionCrossfade transition1And3CrossFade = mVideoEditorHelper.createTCrossFade("transition1And3CrossFade", mediaVideoItem1, mediaVideoItem3, 5000, Transition.BEHAVIOR_MIDDLE_FAST);
    mVideoEditor.addTransition(transition1And3CrossFade);
    final AudioTrack audioTrack = mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioFilename);
    audioTrack.setExtractBoundaries(0, 2000);
    mVideoEditor.addAudioTrack(audioTrack);
    audioTrack.enableLoop();
    mVideoEditor.generatePreview(new MediaProcessingProgressListener() {

        public void onProgress(Object item, int action, int progress) {
        }
    });
    final SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
    mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration() / 4, overlayData1);
    Thread.sleep(1000);
    mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration() / 2, overlayData1);
    Thread.sleep(1000);
    mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration(), overlayData1);
}
Also used : SurfaceHolder(android.view.SurfaceHolder) MediaItem(android.media.videoeditor.MediaItem) MediaVideoItem(android.media.videoeditor.MediaVideoItem) MediaProcessingProgressListener(android.media.videoeditor.VideoEditor.MediaProcessingProgressListener) MediaImageItem(android.media.videoeditor.MediaImageItem) OverlayData(android.media.videoeditor.VideoEditor.OverlayData) AudioTrack(android.media.videoeditor.AudioTrack) TransitionCrossfade(android.media.videoeditor.TransitionCrossfade) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 27 with MediaItem

use of android.media.videoeditor.MediaItem in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorPreviewTest method testPreviewTheStoryBoardFromDuration.

/**
     * To test Preview : Preview of start + 10 sec till end of story board
     */
@LargeTest
public void testPreviewTheStoryBoardFromDuration() throws Exception {
    final String videoItemFileName1 = INPUT_FILE_PATH + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
    final String videoItemFileName2 = INPUT_FILE_PATH + "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
    final String videoItemFileName3 = INPUT_FILE_PATH + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
    final Semaphore blockTillPreviewCompletes = new Semaphore(1);
    previewStart = false;
    previewStop = false;
    final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem1.setExtractBoundaries(0, 10000);
    mVideoEditor.addMediaItem(mediaVideoItem1);
    final MediaVideoItem mediaVideoItem2 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem2", videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem2.setExtractBoundaries(0, 10000);
    mVideoEditor.addMediaItem(mediaVideoItem2);
    final MediaVideoItem mediaVideoItem3 = mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem3", videoItemFileName3, MediaItem.RENDERING_MODE_BLACK_BORDER);
    mediaVideoItem3.setExtractBoundaries(0, 10000);
    mVideoEditor.insertMediaItem(mediaVideoItem3, mediaVideoItem1.getId());
    List<MediaItem> mediaList = mVideoEditor.getAllMediaItems();
    assertEquals("Media Item 1", mediaVideoItem1, mediaList.get(0));
    assertEquals("Media Item 3", mediaVideoItem3, mediaList.get(1));
    assertEquals("Media Item 2", mediaVideoItem2, mediaList.get(2));
    mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER);
    assertEquals("Media Item 1 Rendering Mode", MediaItem.RENDERING_MODE_BLACK_BORDER, mediaVideoItem1.getRenderingMode());
    mediaVideoItem2.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER);
    assertEquals("Media Item 2 Rendering Mode", MediaItem.RENDERING_MODE_BLACK_BORDER, mediaVideoItem2.getRenderingMode());
    mediaVideoItem3.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH);
    assertEquals("Media Item 3 Rendering Mode", MediaItem.RENDERING_MODE_STRETCH, mediaVideoItem3.getRenderingMode());
    mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_5_3);
    assertEquals("Aspect Ratio", MediaProperties.ASPECT_RATIO_5_3, mVideoEditor.getAspectRatio());
    validatePreviewProgress(10000, -1, false, mVideoEditor.getDuration());
}
Also used : MediaItem(android.media.videoeditor.MediaItem) MediaVideoItem(android.media.videoeditor.MediaVideoItem) Semaphore(java.util.concurrent.Semaphore) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 28 with MediaItem

use of android.media.videoeditor.MediaItem in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorImpl method save.

/*
     * {@inheritDoc}
     */
public void save() throws IOException {
    final XmlSerializer serializer = Xml.newSerializer();
    final StringWriter writer = new StringWriter();
    serializer.setOutput(writer);
    serializer.startDocument("UTF-8", true);
    serializer.startTag("", TAG_PROJECT);
    serializer.attribute("", ATTR_ASPECT_RATIO, Integer.toString(mAspectRatio));
    serializer.attribute("", ATTR_REGENERATE_PCM, Boolean.toString(mMANativeHelper.getAudioflag()));
    serializer.startTag("", TAG_MEDIA_ITEMS);
    for (MediaItem mediaItem : mMediaItems) {
        serializer.startTag("", TAG_MEDIA_ITEM);
        serializer.attribute("", ATTR_ID, mediaItem.getId());
        serializer.attribute("", ATTR_TYPE, mediaItem.getClass().getSimpleName());
        serializer.attribute("", ATTR_FILENAME, mediaItem.getFilename());
        serializer.attribute("", ATTR_RENDERING_MODE, Integer.toString(mediaItem.getRenderingMode()));
        if (mediaItem instanceof MediaVideoItem) {
            final MediaVideoItem mvi = (MediaVideoItem) mediaItem;
            serializer.attribute("", ATTR_BEGIN_TIME, Long.toString(mvi.getBoundaryBeginTime()));
            serializer.attribute("", ATTR_END_TIME, Long.toString(mvi.getBoundaryEndTime()));
            serializer.attribute("", ATTR_VOLUME, Integer.toString(mvi.getVolume()));
            serializer.attribute("", ATTR_MUTED, Boolean.toString(mvi.isMuted()));
            if (mvi.getAudioWaveformFilename() != null) {
                serializer.attribute("", ATTR_AUDIO_WAVEFORM_FILENAME, mvi.getAudioWaveformFilename());
            }
        } else if (mediaItem instanceof MediaImageItem) {
            serializer.attribute("", ATTR_DURATION, Long.toString(mediaItem.getTimelineDuration()));
        }
        final List<Overlay> overlays = mediaItem.getAllOverlays();
        if (overlays.size() > 0) {
            serializer.startTag("", TAG_OVERLAYS);
            for (Overlay overlay : overlays) {
                serializer.startTag("", TAG_OVERLAY);
                serializer.attribute("", ATTR_ID, overlay.getId());
                serializer.attribute("", ATTR_TYPE, overlay.getClass().getSimpleName());
                serializer.attribute("", ATTR_BEGIN_TIME, Long.toString(overlay.getStartTime()));
                serializer.attribute("", ATTR_DURATION, Long.toString(overlay.getDuration()));
                if (overlay instanceof OverlayFrame) {
                    final OverlayFrame overlayFrame = (OverlayFrame) overlay;
                    overlayFrame.save(getPath());
                    if (overlayFrame.getBitmapImageFileName() != null) {
                        serializer.attribute("", ATTR_FILENAME, overlayFrame.getBitmapImageFileName());
                    }
                    if (overlayFrame.getFilename() != null) {
                        serializer.attribute("", ATTR_OVERLAY_RGB_FILENAME, overlayFrame.getFilename());
                        serializer.attribute("", ATTR_OVERLAY_FRAME_WIDTH, Integer.toString(overlayFrame.getOverlayFrameWidth()));
                        serializer.attribute("", ATTR_OVERLAY_FRAME_HEIGHT, Integer.toString(overlayFrame.getOverlayFrameHeight()));
                        serializer.attribute("", ATTR_OVERLAY_RESIZED_RGB_FRAME_WIDTH, Integer.toString(overlayFrame.getResizedRGBSizeWidth()));
                        serializer.attribute("", ATTR_OVERLAY_RESIZED_RGB_FRAME_HEIGHT, Integer.toString(overlayFrame.getResizedRGBSizeHeight()));
                    }
                }
                /**
                     *  Save the user attributes
                     */
                serializer.startTag("", TAG_OVERLAY_USER_ATTRIBUTES);
                final Map<String, String> userAttributes = overlay.getUserAttributes();
                for (String name : userAttributes.keySet()) {
                    final String value = userAttributes.get(name);
                    if (value != null) {
                        serializer.attribute("", name, value);
                    }
                }
                serializer.endTag("", TAG_OVERLAY_USER_ATTRIBUTES);
                serializer.endTag("", TAG_OVERLAY);
            }
            serializer.endTag("", TAG_OVERLAYS);
        }
        final List<Effect> effects = mediaItem.getAllEffects();
        if (effects.size() > 0) {
            serializer.startTag("", TAG_EFFECTS);
            for (Effect effect : effects) {
                serializer.startTag("", TAG_EFFECT);
                serializer.attribute("", ATTR_ID, effect.getId());
                serializer.attribute("", ATTR_TYPE, effect.getClass().getSimpleName());
                serializer.attribute("", ATTR_BEGIN_TIME, Long.toString(effect.getStartTime()));
                serializer.attribute("", ATTR_DURATION, Long.toString(effect.getDuration()));
                if (effect instanceof EffectColor) {
                    final EffectColor colorEffect = (EffectColor) effect;
                    serializer.attribute("", ATTR_COLOR_EFFECT_TYPE, Integer.toString(colorEffect.getType()));
                    if (colorEffect.getType() == EffectColor.TYPE_COLOR || colorEffect.getType() == EffectColor.TYPE_GRADIENT) {
                        serializer.attribute("", ATTR_COLOR_EFFECT_VALUE, Integer.toString(colorEffect.getColor()));
                    }
                } else if (effect instanceof EffectKenBurns) {
                    final Rect startRect = ((EffectKenBurns) effect).getStartRect();
                    serializer.attribute("", ATTR_START_RECT_LEFT, Integer.toString(startRect.left));
                    serializer.attribute("", ATTR_START_RECT_TOP, Integer.toString(startRect.top));
                    serializer.attribute("", ATTR_START_RECT_RIGHT, Integer.toString(startRect.right));
                    serializer.attribute("", ATTR_START_RECT_BOTTOM, Integer.toString(startRect.bottom));
                    final Rect endRect = ((EffectKenBurns) effect).getEndRect();
                    serializer.attribute("", ATTR_END_RECT_LEFT, Integer.toString(endRect.left));
                    serializer.attribute("", ATTR_END_RECT_TOP, Integer.toString(endRect.top));
                    serializer.attribute("", ATTR_END_RECT_RIGHT, Integer.toString(endRect.right));
                    serializer.attribute("", ATTR_END_RECT_BOTTOM, Integer.toString(endRect.bottom));
                    final MediaItem mItem = effect.getMediaItem();
                    if (((MediaImageItem) mItem).getGeneratedImageClip() != null) {
                        serializer.attribute("", ATTR_IS_IMAGE_CLIP_GENERATED, Boolean.toString(true));
                        serializer.attribute("", ATTR_GENERATED_IMAGE_CLIP, ((MediaImageItem) mItem).getGeneratedImageClip());
                    } else {
                        serializer.attribute("", ATTR_IS_IMAGE_CLIP_GENERATED, Boolean.toString(false));
                    }
                }
                serializer.endTag("", TAG_EFFECT);
            }
            serializer.endTag("", TAG_EFFECTS);
        }
        serializer.endTag("", TAG_MEDIA_ITEM);
    }
    serializer.endTag("", TAG_MEDIA_ITEMS);
    serializer.startTag("", TAG_TRANSITIONS);
    for (Transition transition : mTransitions) {
        serializer.startTag("", TAG_TRANSITION);
        serializer.attribute("", ATTR_ID, transition.getId());
        serializer.attribute("", ATTR_TYPE, transition.getClass().getSimpleName());
        serializer.attribute("", ATTR_DURATION, Long.toString(transition.getDuration()));
        serializer.attribute("", ATTR_BEHAVIOR, Integer.toString(transition.getBehavior()));
        serializer.attribute("", ATTR_IS_TRANSITION_GENERATED, Boolean.toString(transition.isGenerated()));
        if (transition.isGenerated() == true) {
            serializer.attribute("", ATTR_GENERATED_TRANSITION_CLIP, transition.mFilename);
        }
        final MediaItem afterMediaItem = transition.getAfterMediaItem();
        if (afterMediaItem != null) {
            serializer.attribute("", ATTR_AFTER_MEDIA_ITEM_ID, afterMediaItem.getId());
        }
        final MediaItem beforeMediaItem = transition.getBeforeMediaItem();
        if (beforeMediaItem != null) {
            serializer.attribute("", ATTR_BEFORE_MEDIA_ITEM_ID, beforeMediaItem.getId());
        }
        if (transition instanceof TransitionSliding) {
            serializer.attribute("", ATTR_DIRECTION, Integer.toString(((TransitionSliding) transition).getDirection()));
        } else if (transition instanceof TransitionAlpha) {
            TransitionAlpha ta = (TransitionAlpha) transition;
            serializer.attribute("", ATTR_BLENDING, Integer.toString(ta.getBlendingPercent()));
            serializer.attribute("", ATTR_INVERT, Boolean.toString(ta.isInvert()));
            if (ta.getMaskFilename() != null) {
                serializer.attribute("", ATTR_MASK, ta.getMaskFilename());
            }
        }
        serializer.endTag("", TAG_TRANSITION);
    }
    serializer.endTag("", TAG_TRANSITIONS);
    serializer.startTag("", TAG_AUDIO_TRACKS);
    for (AudioTrack at : mAudioTracks) {
        serializer.startTag("", TAG_AUDIO_TRACK);
        serializer.attribute("", ATTR_ID, at.getId());
        serializer.attribute("", ATTR_FILENAME, at.getFilename());
        serializer.attribute("", ATTR_START_TIME, Long.toString(at.getStartTime()));
        serializer.attribute("", ATTR_BEGIN_TIME, Long.toString(at.getBoundaryBeginTime()));
        serializer.attribute("", ATTR_END_TIME, Long.toString(at.getBoundaryEndTime()));
        serializer.attribute("", ATTR_VOLUME, Integer.toString(at.getVolume()));
        serializer.attribute("", ATTR_DUCK_ENABLED, Boolean.toString(at.isDuckingEnabled()));
        serializer.attribute("", ATTR_DUCKED_TRACK_VOLUME, Integer.toString(at.getDuckedTrackVolume()));
        serializer.attribute("", ATTR_DUCK_THRESHOLD, Integer.toString(at.getDuckingThreshhold()));
        serializer.attribute("", ATTR_MUTED, Boolean.toString(at.isMuted()));
        serializer.attribute("", ATTR_LOOP, Boolean.toString(at.isLooping()));
        if (at.getAudioWaveformFilename() != null) {
            serializer.attribute("", ATTR_AUDIO_WAVEFORM_FILENAME, at.getAudioWaveformFilename());
        }
        serializer.endTag("", TAG_AUDIO_TRACK);
    }
    serializer.endTag("", TAG_AUDIO_TRACKS);
    serializer.endTag("", TAG_PROJECT);
    serializer.endDocument();
    /**
         *  Save the metadata XML file
         */
    final FileOutputStream out = new FileOutputStream(new File(getPath(), PROJECT_FILENAME));
    out.write(writer.toString().getBytes());
    out.flush();
    out.close();
}
Also used : Rect(android.graphics.Rect) MediaImageItem(android.media.videoeditor.MediaImageItem) StringWriter(java.io.StringWriter) MediaItem(android.media.videoeditor.MediaItem) FileOutputStream(java.io.FileOutputStream) File(java.io.File) XmlSerializer(org.xmlpull.v1.XmlSerializer)

Example 29 with MediaItem

use of android.media.videoeditor.MediaItem in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorImpl method generateProjectThumbnail.

/*
     * Generate the project thumbnail
     */
private void generateProjectThumbnail() {
    /*
         * If a thumbnail already exists, then delete it first
         */
    if ((new File(mProjectPath + "/" + THUMBNAIL_FILENAME)).exists()) {
        (new File(mProjectPath + "/" + THUMBNAIL_FILENAME)).delete();
    }
    /*
         * Generate a new thumbnail for the project from first media Item
         */
    if (mMediaItems.size() > 0) {
        MediaItem mI = mMediaItems.get(0);
        /*
             * Keep aspect ratio of the image
             */
        int height = 480;
        int width = mI.getWidth() * height / mI.getHeight();
        Bitmap projectBitmap = null;
        String filename = mI.getFilename();
        if (mI instanceof MediaVideoItem) {
            MediaMetadataRetriever retriever = new MediaMetadataRetriever();
            retriever.setDataSource(filename);
            Bitmap bitmap = retriever.getFrameAtTime();
            retriever.release();
            retriever = null;
            if (bitmap == null) {
                String msg = "Thumbnail extraction from " + filename + " failed";
                throw new IllegalArgumentException(msg);
            }
            // Resize the thumbnail to the target size
            projectBitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
        } else {
            try {
                projectBitmap = mI.getThumbnail(width, height, 500);
            } catch (IllegalArgumentException e) {
                String msg = "Project thumbnail extraction from " + filename + " failed";
                throw new IllegalArgumentException(msg);
            } catch (IOException e) {
                String msg = "IO Error creating project thumbnail";
                throw new IllegalArgumentException(msg);
            }
        }
        try {
            FileOutputStream stream = new FileOutputStream(mProjectPath + "/" + THUMBNAIL_FILENAME);
            projectBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
            stream.flush();
            stream.close();
        } catch (IOException e) {
            throw new IllegalArgumentException("Error creating project thumbnail");
        } finally {
            projectBitmap.recycle();
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) MediaItem(android.media.videoeditor.MediaItem) MediaMetadataRetriever(android.media.MediaMetadataRetriever) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 30 with MediaItem

use of android.media.videoeditor.MediaItem in project android_frameworks_base by ParanoidAndroid.

the class VideoEditorImpl method removeTransitionBefore.

/**
     * Remove the transition before this media item
     *
     * @param index The media item index
     */
private void removeTransitionBefore(int index) {
    final MediaItem mediaItem = mMediaItems.get(index);
    final Iterator<Transition> it = mTransitions.iterator();
    while (it.hasNext()) {
        Transition t = it.next();
        if (t.getBeforeMediaItem() == mediaItem) {
            mMANativeHelper.setGeneratePreview(true);
            it.remove();
            t.invalidate();
            mediaItem.setBeginTransition(null);
            if (index > 0) {
                mMediaItems.get(index - 1).setEndTransition(null);
            }
            break;
        }
    }
}
Also used : MediaItem(android.media.videoeditor.MediaItem)

Aggregations

MediaItem (android.media.videoeditor.MediaItem)35 MediaImageItem (android.media.videoeditor.MediaImageItem)11 File (java.io.File)8 MediaVideoItem (android.media.videoeditor.MediaVideoItem)5 LargeTest (android.test.suitebuilder.annotation.LargeTest)5 FileOutputStream (java.io.FileOutputStream)4 IOException (java.io.IOException)4 Bitmap (android.graphics.Bitmap)3 TransitionCrossfade (android.media.videoeditor.TransitionCrossfade)3 Rect (android.graphics.Rect)2 MediaMetadataRetriever (android.media.MediaMetadataRetriever)2 AudioTrack (android.media.videoeditor.AudioTrack)2 MediaProcessingProgressListener (android.media.videoeditor.VideoEditor.MediaProcessingProgressListener)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 StringWriter (java.io.StringWriter)2 ArrayList (java.util.ArrayList)2 XmlPullParser (org.xmlpull.v1.XmlPullParser)2 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2 XmlSerializer (org.xmlpull.v1.XmlSerializer)2