4 changed files with 121 additions and 1 deletions
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
package apelet.association.plugin.course; |
||||
|
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
|
||||
public class courseFormPlugin extends ExecutePluginParent |
||||
{ |
||||
@Override |
||||
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||
super.formCreated(widgetVariableName, objectValue); |
||||
if(objectValue.get("isEnabled") == null){ |
||||
this.setWidgetAttribute("isEnabled", AttributeEnum.VALUE_CHANGE,0); |
||||
} |
||||
if(objectValue.get("faceCapture") == null){ |
||||
this.setWidgetAttribute("faceCapture", AttributeEnum.VALUE_CHANGE,0); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package apelet.association.plugin.courseCourseware; |
||||
|
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
|
||||
public class CourseCoursewareFromPlugin extends ExecutePluginParent{ |
||||
@Override |
||||
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||
super.formCreated(widgetVariableName, objectValue); |
||||
if(objectValue.get("isSeqLock") == null){ |
||||
this.setWidgetAttribute("isSeqLock", AttributeEnum.VALUE_CHANGE,0); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
package apelet.association.plugin.courseVideo; |
||||
|
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.online.abstractplugin.ExecutePluginParent; |
||||
import apelet.common.online.model.constant.AttributeEnum; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import org.bytedeco.javacv.FFmpegFrameGrabber; |
||||
|
||||
import java.io.File; |
||||
import java.net.URL; |
||||
|
||||
public class CourseVideoFormPlugin extends ExecutePluginParent { |
||||
@Override |
||||
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
||||
super.formCreated(widgetVariableName, objectValue); |
||||
} |
||||
|
||||
@Override |
||||
public void uploadSuccess(String widgetVariableName, ObjectValue objectValue) { |
||||
super.uploadSuccess(widgetVariableName, objectValue); |
||||
Object fileName = objectValue.get("file_name"); |
||||
|
||||
if (fileName != null) { |
||||
JSONArray fileJson = JSON.parseArray(fileName.toString()); |
||||
if (!fileJson.isEmpty()) { |
||||
this.setWidgetAttribute("fileName", AttributeEnum.DISABLED, true); |
||||
} |
||||
JSONObject item = fileJson.getJSONObject(0); |
||||
String realName = item.getString("fileRealName"); |
||||
String fullFilePath = item.getString("uploadPath") + "/" + item.getString("filename"); |
||||
|
||||
File file = new File(fullFilePath); |
||||
|
||||
|
||||
long durationSec = 0; |
||||
FFmpegFrameGrabber grabber = null; |
||||
try { |
||||
// 核心:直接传入字符串,自动识别本地文件 / 网络URL
|
||||
grabber = new FFmpegFrameGrabber(fullFilePath); |
||||
grabber.start(); |
||||
|
||||
// 微秒 → 毫秒 → 秒
|
||||
long totalMicroSeconds = grabber.getLengthInTime(); |
||||
long totalMs = totalMicroSeconds / 1000; |
||||
durationSec = totalMs / 1000; |
||||
|
||||
} catch (Exception e) { |
||||
throw new RuntimeException("解析音视频时长失败,资源地址:" + fullFilePath, e); |
||||
} finally { |
||||
// 强制释放资源,避免句柄、网络连接泄漏
|
||||
if (grabber != null) { |
||||
try { |
||||
grabber.stop(); |
||||
grabber.close(); |
||||
} catch (Exception ignore) { |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue