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());
}
}
}
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;
}
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));
}
Aggregations