Search in sources :

Example 1 with VideoFileResource

use of org.olat.fileresource.types.VideoFileResource in project OpenOLAT by OpenOLAT.

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;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VideoFileResource(org.olat.fileresource.types.VideoFileResource) FileResource(org.olat.fileresource.types.FileResource) VideoFileResource(org.olat.fileresource.types.VideoFileResource) OLATResource(org.olat.resource.OLATResource) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) VideoManager(org.olat.modules.video.VideoManager) RepositoryService(org.olat.repository.RepositoryService)

Example 2 with VideoFileResource

use of org.olat.fileresource.types.VideoFileResource 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;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VideoFileResource(org.olat.fileresource.types.VideoFileResource) FileResource(org.olat.fileresource.types.FileResource) VideoFileResource(org.olat.fileresource.types.VideoFileResource) OLATResource(org.olat.resource.OLATResource) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) VideoManager(org.olat.modules.video.VideoManager) RepositoryService(org.olat.repository.RepositoryService)

Aggregations

LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 FileResource (org.olat.fileresource.types.FileResource)2 VideoFileResource (org.olat.fileresource.types.VideoFileResource)2 VideoManager (org.olat.modules.video.VideoManager)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 RepositoryService (org.olat.repository.RepositoryService)2 OLATResource (org.olat.resource.OLATResource)2