use of org.olat.modules.video.manager.VideoMediaMapper in project OpenOLAT by OpenOLAT.
the class VideoPosterEditController method updatePosterImage.
private void updatePosterImage(UserRequest ureq, OLATResource video) {
VFSLeaf posterFile = videoManager.getPosterframe(video);
VFSContainer masterContainer = posterFile.getParentContainer();
VideoMediaMapper mediaMapper = new VideoMediaMapper(masterContainer);
String mediaUrl = registerMapper(ureq, mediaMapper);
String serverUrl = Settings.createServerURI();
displayContainer.contextPut("serverUrl", serverUrl);
displayContainer.contextPut("mediaUrl", mediaUrl);
displayContainer.setDirty(true);
}
use of org.olat.modules.video.manager.VideoMediaMapper in project OpenOLAT by OpenOLAT.
the class VideoQualityTableFormController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormLink && ((FormLink) source).getCmd().equals("viewQuality")) {
if (cmc == null) {
// initialize preview controller only once
previewVC = createVelocityContainer("video_preview");
cmc = new CloseableModalController(getWindowControl(), "close", previewVC);
listenTo(cmc);
}
// Get the user object from the link to access version object
FormLink link = (FormLink) source;
VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
if (videoTranscoding == null) {
// this is the master video
// VideoMetadata videoMetadata = videoManager.readVideoMetadataFile(videoResource);
VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
previewVC.contextPut("width", videoMetadata.getWidth());
previewVC.contextPut("height", videoMetadata.getHeight());
previewVC.contextPut("filename", "video.mp4");
VFSContainer container = videoManager.getMasterContainer(videoResource);
String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
previewVC.contextPut("mediaUrl", transcodedUrl);
} else {
// this is a version
previewVC.contextPut("width", videoTranscoding.getWidth());
previewVC.contextPut("height", videoTranscoding.getHeight());
previewVC.contextPut("filename", videoTranscoding.getResolution() + "video.mp4");
VFSContainer container = videoManager.getTranscodingContainer(videoResource);
String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
previewVC.contextPut("mediaUrl", transcodedUrl);
}
// activate dialog to bring it in front
cmc.activate();
} else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("deleteQuality")) {
FormLink link = (FormLink) source;
VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
videoManager.deleteVideoTranscoding(videoTranscoding);
} else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("startTranscoding")) {
videoManager.createTranscoding(videoResource, (int) source.getUserObject(), "mp4");
}
initTable();
}
use of org.olat.modules.video.manager.VideoMediaMapper in project openolat by klemens.
the class VideoDisplayController method loadVideo.
/**
* Internal helper to do the actual video loading, checking for transcoded versions and captions
* @param ureq
* @param video
*/
private void loadVideo(UserRequest ureq, VFSLeaf video) {
mainVC.contextPut("title", entry.getDisplayname());
String desc = (descriptionText != null ? descriptionText : entry.getDescription());
setText(desc, "description");
String authors = entry.getAuthors();
mainVC.contextPut("authors", (StringHelper.containsNonWhitespace(authors) ? authors : null));
if (video != null) {
// get resolution of master video resource
Size masterResolution = videoManager.getVideoResolutionFromOLATResource(entry.getOlatResource());
String masterTitle = videoManager.getDisplayTitleForResolution(masterResolution.getHeight(), getTranslator());
String masterSize = " (" + Formatter.formatBytes(videoManager.getVideoMetadata(entry.getOlatResource()).getSize()) + ")";
boolean addMaster = true;
// Mapper for Video
String masterMapperId = "master-" + entry.getOlatResource().getResourceableId();
String masterUrl = registerCacheableMapper(ureq, masterMapperId, new VideoMediaMapper(videoManager.getMasterContainer(entry.getOlatResource())));
mainVC.contextPut("masterUrl", masterUrl);
// Mapper for versions specific because not in same base as the resource itself
String transcodingMapperId = "transcoding-" + entry.getOlatResource().getResourceableId();
VFSContainer transcodedContainer = videoManager.getTranscodingContainer(entry.getOlatResource());
String transcodedUrl = registerCacheableMapper(ureq, transcodingMapperId, new VideoMediaMapper(transcodedContainer));
mainVC.contextPut("transcodedUrl", transcodedUrl);
// Add transcoded versions
List<VideoTranscoding> videos = videoManager.getVideoTranscodings(entry.getOlatResource());
List<VideoTranscoding> readyToPlayVideos = new ArrayList<>();
List<String> displayTitles = new ArrayList<>();
int preferredAvailableResolution = 0;
for (VideoTranscoding videoTranscoding : videos) {
if (videoTranscoding.getStatus() == VideoTranscoding.TRANSCODING_STATUS_DONE) {
readyToPlayVideos.add(videoTranscoding);
// Check if at least one has equal height, else use master as resource
addMaster &= videoTranscoding.getHeight() < masterResolution.getHeight();
// Use the users preferred resolution or the next higher resolution
if (videoTranscoding.getResolution() >= userPreferredResolution.intValue()) {
preferredAvailableResolution = readyToPlayVideos.size() - 1;
}
// Calculate title. Standard title for standard resolution, original title if not standard resolution
String title = videoManager.getDisplayTitleForResolution(videoTranscoding.getResolution(), getTranslator());
displayTitles.add(title);
}
}
mainVC.contextPut("addMaster", addMaster);
mainVC.contextPut("masterTitle", masterTitle + masterSize);
mainVC.contextPut("videos", readyToPlayVideos);
mainVC.contextPut("displayTitles", displayTitles);
mainVC.contextPut("useSourceChooser", Boolean.valueOf(readyToPlayVideos.size() > 1));
mainVC.contextPut(GUIPREF_KEY_PREFERRED_RESOLUTION, preferredAvailableResolution);
// Check for null-value posters
VFSLeaf poster = videoManager.getPosterframe(entry.getOlatResource());
mainVC.contextPut("usePoster", Boolean.valueOf(poster != null && poster.getSize() > 0));
// Load the track from config
Map<String, String> trackfiles = new HashMap<String, String>();
Map<String, VFSLeaf> configTracks = videoManager.getAllTracks(entry.getOlatResource());
for (HashMap.Entry<String, VFSLeaf> track : configTracks.entrySet()) {
trackfiles.put(track.getKey(), track.getValue().getName());
}
mainVC.contextPut("trackfiles", trackfiles);
// Load video chapter if available
mainVC.contextPut("hasChapters", videoManager.hasChapters(entry.getOlatResource()));
// Add duration without preloading video
String duration = entry.getExpenditureOfWork();
if (!StringHelper.containsNonWhitespace(duration)) {
duration = "00:00";
}
mainVC.contextPut("duration", duration);
}
}
use of org.olat.modules.video.manager.VideoMediaMapper in project openolat by klemens.
the class VideoPosterEditController method updatePosterImage.
private void updatePosterImage(UserRequest ureq, OLATResource video) {
VFSLeaf posterFile = videoManager.getPosterframe(video);
VFSContainer masterContainer = posterFile.getParentContainer();
VideoMediaMapper mediaMapper = new VideoMediaMapper(masterContainer);
String mediaUrl = registerMapper(ureq, mediaMapper);
String serverUrl = Settings.createServerURI();
displayContainer.contextPut("serverUrl", serverUrl);
displayContainer.contextPut("mediaUrl", mediaUrl);
displayContainer.setDirty(true);
}
use of org.olat.modules.video.manager.VideoMediaMapper in project openolat by klemens.
the class VideoQualityTableFormController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof FormLink && ((FormLink) source).getCmd().equals("viewQuality")) {
if (cmc == null) {
// initialize preview controller only once
previewVC = createVelocityContainer("video_preview");
cmc = new CloseableModalController(getWindowControl(), "close", previewVC);
listenTo(cmc);
}
// Get the user object from the link to access version object
FormLink link = (FormLink) source;
VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
if (videoTranscoding == null) {
// this is the master video
// VideoMetadata videoMetadata = videoManager.readVideoMetadataFile(videoResource);
VideoMeta videoMetadata = videoManager.getVideoMetadata(videoResource);
previewVC.contextPut("width", videoMetadata.getWidth());
previewVC.contextPut("height", videoMetadata.getHeight());
previewVC.contextPut("filename", "video.mp4");
VFSContainer container = videoManager.getMasterContainer(videoResource);
String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
previewVC.contextPut("mediaUrl", transcodedUrl);
} else {
// this is a version
previewVC.contextPut("width", videoTranscoding.getWidth());
previewVC.contextPut("height", videoTranscoding.getHeight());
previewVC.contextPut("filename", videoTranscoding.getResolution() + "video.mp4");
VFSContainer container = videoManager.getTranscodingContainer(videoResource);
String transcodedUrl = registerMapper(ureq, new VideoMediaMapper(container));
previewVC.contextPut("mediaUrl", transcodedUrl);
}
// activate dialog to bring it in front
cmc.activate();
} else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("deleteQuality")) {
FormLink link = (FormLink) source;
VideoTranscoding videoTranscoding = (VideoTranscoding) link.getUserObject();
videoManager.deleteVideoTranscoding(videoTranscoding);
} else if (source instanceof FormLink && ((FormLink) source).getCmd().equals("startTranscoding")) {
videoManager.createTranscoding(videoResource, (int) source.getUserObject(), "mp4");
}
initTable();
}
Aggregations