Search in sources :

Example 1 with SubtimelineVisualClip

use of com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip in project tactview by helospark.

the class ReplaceTimelineWithSubtimelineCommand method execute.

@Override
public void execute() {
    synchronized (timelineManagerAccessor.getFullLock()) {
        SubtimelineVisualClip newVideoClip = null;
        SubtimelineAudioClip newAudioClip = null;
        if (projectRepository.isVideoInitialized()) {
            newVideoClip = subtimelineFromTimelineFactory.createSubtimelineVideoClipFromCurrentTimeline(exposedDescriptors);
        }
        if (projectRepository.isAudioInitialized()) {
            newAudioClip = subtimelineFromTimelineFactory.createSubtimelineAudioClipFromCurrentTimeline(exposedDescriptors);
        }
        for (var id : timelineManagerAccessor.getAllClipIds()) {
            TimelineChannel channel = timelineManagerAccessor.findChannelForClipId(id).get();
            TimelineClip clip = timelineManagerAccessor.findClipById(id).get().cloneClip(CloneRequestMetadata.fullCopy());
            clipsRemoved.add(new ChannelClipPair(channel, clip));
            timelineManagerAccessor.removeClip(id);
        }
        if (newVideoClip != null) {
            timelineManagerAccessor.addClip(timelineManagerAccessor.getChannels().get(0), newVideoClip);
            addedIds.add(newVideoClip.getId());
        }
        if (newAudioClip != null) {
            timelineManagerAccessor.addClip(timelineManagerAccessor.getChannels().get(1), newAudioClip);
            addedIds.add(newAudioClip.getId());
        }
        if (newVideoClip != null && newAudioClip != null) {
            linkClipRepository.linkClip(newVideoClip.getId(), newAudioClip.getId());
        }
    }
}
Also used : TimelineChannel(com.helospark.tactview.core.timeline.TimelineChannel) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip) TimelineClip(com.helospark.tactview.core.timeline.TimelineClip)

Example 2 with SubtimelineVisualClip

use of com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip in project tactview by helospark.

the class SubtimelineFromTimelineFactory method createSubtimelineVideoClipFromCurrentTimeline.

public SubtimelineVisualClip createSubtimelineVideoClipFromCurrentTimeline(Set<ExposedDescriptorDescriptor> exposedDescriptors) {
    TimelineLength length = timelineManager.findEndPosition().toLength();
    SubtimelineVisualMetadata metadata = SubtimelineVisualMetadata.builder().withWidth(projectRepository.getWidth()).withHeight(projectRepository.getHeight()).withResizable(true).withLength(length).build();
    CloneRequestMetadata cloneMetadata = CloneRequestMetadata.ofDefault();
    TimelineChannelsState clonedState = timelineChannelsState.deepClone(cloneMetadata);
    Set<ExposedDescriptorDescriptor> fixedExposedDescriptors = exposedDescriptors.stream().map(a -> a.butWithId(cloneMetadata.getPreviousId(a.getId()))).collect(Collectors.toSet());
    SubtimelineVisualClip result = new SubtimelineVisualClip(metadata, clonedState, timelineManagerAccessorFactory, subtimelineHelper, fixedExposedDescriptors, TimelinePosition.ofZero(), length);
    result.setCreatorFactoryId(SubtimelineVisualClipFactory.ID);
    return result;
}
Also used : TimelineChannelsState(com.helospark.tactview.core.timeline.TimelineChannelsState) Component(com.helospark.lightdi.annotation.Component) AudioMediaMetadata(com.helospark.tactview.core.decoder.AudioMediaMetadata) TimelinePosition(com.helospark.tactview.core.timeline.TimelinePosition) Set(java.util.Set) Collectors(java.util.stream.Collectors) TimelineLength(com.helospark.tactview.core.timeline.TimelineLength) CloneRequestMetadata(com.helospark.tactview.core.clone.CloneRequestMetadata) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) SubtimelineAudioClipFactory(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClipFactory) ProjectRepository(com.helospark.tactview.core.repository.ProjectRepository) SubtimelineVisualClipFactory(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClipFactory) SubtimelineVisualMetadata(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualMetadata) TimelineChannelsState(com.helospark.tactview.core.timeline.TimelineChannelsState) SubtimelineVisualMetadata(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualMetadata) CloneRequestMetadata(com.helospark.tactview.core.clone.CloneRequestMetadata) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip) TimelineLength(com.helospark.tactview.core.timeline.TimelineLength)

Example 3 with SubtimelineVisualClip

use of com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip in project tactview by helospark.

the class TemplateSaveAndLoadHandler method queryAdditionalDataToSave.

protected void queryAdditionalDataToSave(Map<String, Object> result, SaveMetadata saveMetadata, SaveTemplateRequest saveTemplateRequest) {
    if (projectRepository.isVideoInitialized()) {
        SubtimelineVisualClip videoClip = subtimelineFromTimelineFactory.createSubtimelineVideoClipFromCurrentTimeline(saveTemplateRequest.getExposedDescriptors());
        result.put(VIDEO_TRACK_NODE, videoClip.generateSavedContent(saveMetadata));
    }
    if (projectRepository.isAudioInitialized()) {
        SubtimelineAudioClip audioClip = subtimelineFromTimelineFactory.createSubtimelineAudioClipFromCurrentTimeline(saveTemplateRequest.getExposedDescriptors());
        result.put(AUDIO_TRACK_NODE, audioClip.generateSavedContent(saveMetadata));
    }
    context.getListOfBeans(SaveLoadContributor.class).stream().filter(a -> !a.getClass().equals(TimelineManagerAccessor.class)).forEach(a -> a.generateSavedContent(result, saveMetadata));
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Component(com.helospark.lightdi.annotation.Component) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip) SubtimelineFromTimelineFactory(com.helospark.tactview.core.timeline.subtimeline.SubtimelineFromTimelineFactory) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) Map(java.util.Map) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) JsonNode(com.fasterxml.jackson.databind.JsonNode) ProjectRepository(com.helospark.tactview.core.repository.ProjectRepository) LightDiContext(com.helospark.lightdi.LightDiContext) File(java.io.File) TimelineManagerAccessor(com.helospark.tactview.core.timeline.TimelineManagerAccessor) SubtimelineAudioClip(com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip) SubtimelineVisualClip(com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip)

Aggregations

SubtimelineAudioClip (com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClip)3 SubtimelineVisualClip (com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClip)3 Component (com.helospark.lightdi.annotation.Component)2 ProjectRepository (com.helospark.tactview.core.repository.ProjectRepository)2 TimelineManagerAccessor (com.helospark.tactview.core.timeline.TimelineManagerAccessor)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 LightDiContext (com.helospark.lightdi.LightDiContext)1 CloneRequestMetadata (com.helospark.tactview.core.clone.CloneRequestMetadata)1 AudioMediaMetadata (com.helospark.tactview.core.decoder.AudioMediaMetadata)1 TimelineChannel (com.helospark.tactview.core.timeline.TimelineChannel)1 TimelineChannelsState (com.helospark.tactview.core.timeline.TimelineChannelsState)1 TimelineClip (com.helospark.tactview.core.timeline.TimelineClip)1 TimelineLength (com.helospark.tactview.core.timeline.TimelineLength)1 TimelinePosition (com.helospark.tactview.core.timeline.TimelinePosition)1 SubtimelineFromTimelineFactory (com.helospark.tactview.core.timeline.subtimeline.SubtimelineFromTimelineFactory)1 SubtimelineAudioClipFactory (com.helospark.tactview.core.timeline.subtimeline.audio.SubtimelineAudioClipFactory)1 SubtimelineVisualClipFactory (com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualClipFactory)1 SubtimelineVisualMetadata (com.helospark.tactview.core.timeline.subtimeline.video.SubtimelineVisualMetadata)1 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1