Search in sources :

Example 16 with VideoManager

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;
}
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

VideoManager (org.olat.modules.video.VideoManager)16 OLATResource (org.olat.resource.OLATResource)6 IOException (java.io.IOException)4 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 ArrayList (java.util.ArrayList)2 ObjectDeletedException (org.hibernate.ObjectDeletedException)2 Size (org.olat.core.commons.services.image.Size)2 MovieService (org.olat.core.commons.services.video.MovieService)2 NotFoundMediaResource (org.olat.core.gui.media.NotFoundMediaResource)2 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 FileResource (org.olat.fileresource.types.FileResource)2 VideoFileResource (org.olat.fileresource.types.VideoFileResource)2 VideoModule (org.olat.modules.video.VideoModule)2 VideoTranscoding (org.olat.modules.video.VideoTranscoding)2