Skip to content
Snippets Groups Projects
Commit 8c6336d4 authored by srosse's avatar srosse
Browse files

OO-2996: initialize sooner the duration of the video in the chapter editor

parent 14ad1bcc
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,7 @@ import org.olat.core.gui.control.generic.closablewrapper.CloseableModalControlle
import org.olat.core.gui.control.winmgr.JSCommand;
import org.olat.core.util.StringHelper;
import org.olat.modules.video.VideoManager;
import org.olat.modules.video.VideoMeta;
import org.olat.modules.video.ui.VideoChapterTableModel.ChapterTableCols;
import org.olat.repository.RepositoryEntry;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -85,7 +86,6 @@ public class VideoChapterEditController extends BasicController {
displayDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
VelocityContainer mainVC = createVelocityContainer("video_chapter_editor");
//video preview
videoDisplayCtr = new VideoDisplayController(ureq, getWindowControl(), entry, false, false, false, false, null, false, false, null, false);
videoDisplayCtr.setTimeUpdateListener(true);
......@@ -98,9 +98,31 @@ public class VideoChapterEditController extends BasicController {
chaptersEditCtrl = new VideoChaptersController(ureq, getWindowControl());
listenTo(chaptersEditCtrl);
mainVC.put("chapters", chaptersEditCtrl.getInitialComponent());
initDurationInSeconds();
putInitialPanel(mainVC);
}
private void initDurationInSeconds() {
String duration = entry.getExpenditureOfWork();
if (!StringHelper.containsNonWhitespace(duration)) {
VideoMeta metadata = videoDisplayCtr.getVideoMetadata();
if(metadata != null) {
duration = metadata.getLength();
}
}
if(StringHelper.containsNonWhitespace(duration)) {
try {
if(duration.indexOf(':') == duration.lastIndexOf(':')) {
duration = "00:" + duration;
}
durationInSeconds = displayDateFormat.parse(duration).getTime() / 1000;
} catch (Exception e) {
logWarn("Cannot parse expenditure of work: " + duration, e);
}
}
}
@Override
protected void doDispose() {
......@@ -270,7 +292,7 @@ public class VideoChapterEditController extends BasicController {
private void doEditChapter(UserRequest ureq, VideoChapterTableRow videoChapterTableRow, boolean chapterExists) {
if(chapterEditCtr != null) return;
chapterEditCtr = new ChapterEditController(ureq, getWindowControl(), videoChapterTableRow,
chapterExists, tableModel.getObjects(), durationInSeconds);
listenTo(chapterEditCtr);
......
......@@ -79,7 +79,7 @@ public class VideoDisplayController extends BasicController {
private RepositoryEntry entry;
private String descriptionText;
private String mediaRepoBaseUrl;
private VideoMeta videoMetadata;
public VideoDisplayController(UserRequest ureq, WindowControl wControl, RepositoryEntry entry, boolean autoWidth) {
this(ureq, wControl, entry, false, false, false, true, null, false, autoWidth, null, false);
......@@ -108,7 +108,7 @@ public class VideoDisplayController extends BasicController {
VFSLeaf video = videoManager.getMasterVideoFile(entry.getOlatResource());
if(video != null) {
VideoMeta videoMetadata = videoManager.getVideoMetadata(entry.getOlatResource());
videoMetadata = videoManager.getVideoMetadata(entry.getOlatResource());
if(autoWidth){
mainVC.contextPut("height", 480);
mainVC.contextPut("width", "100%");
......@@ -145,6 +145,10 @@ public class VideoDisplayController extends BasicController {
}
}
public VideoMeta getVideoMetadata() {
return videoMetadata;
}
public void setTimeUpdateListener(boolean enable) {
mainVC.contextPut("listenTimeUpdate", enable);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment