use of org.olat.modules.video.VideoManager in project openolat by klemens.
the class VideoHandler method importResource.
@Override
public RepositoryEntry importResource(Identity initialAuthor, String initialAuthorAlt, String displayname, String description, boolean withReferences, Locale locale, File file, String fileName) {
// 1) Create resource and repository entry
FileResource ores = new VideoFileResource();
OLATResource resource = OLATResourceManager.getInstance().createAndPersistOLATResourceInstance(ores);
RepositoryEntry repoEntry = CoreSpringFactory.getImpl(RepositoryService.class).create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
if (fileName == null) {
fileName = file.getName();
}
fileName = fileName.toLowerCase();
VFSLeaf importFile = new LocalFileImpl(file);
long filesize = importFile.getSize();
VideoManager videoManager = CoreSpringFactory.getImpl(VideoManager.class);
if (fileName.endsWith(".mp4") || fileName.endsWith(".mov") || fileName.endsWith(".m4v")) {
// 2a) import video from raw mp4 master video file
videoManager.importFromMasterFile(repoEntry, importFile);
} else if (fileName.endsWith(".zip")) {
// 2b) import video from archive from another OpenOLAT instance
DBFactory.getInstance().commit();
videoManager.importFromExportArchive(repoEntry, importFile);
}
// 3) Persist Meta data
videoManager.createVideoMetadata(repoEntry, filesize, fileName);
DBFactory.getInstance().commit();
// 4) start transcoding process if enabled
videoManager.startTranscodingProcessIfEnabled(resource);
return repoEntry;
}
Aggregations