|
@@ -14,7 +14,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="form-group col-sm-2">
|
|
|
- <label class="control-label">课程视频</label>
|
|
|
+ <label class="control-label">课程视频 [720P]</label>
|
|
|
<div id="video_src">
|
|
|
<a id="video_upload" href="javascript:;" class="img-thumb" >
|
|
|
<video src="{{path_compat('')}}" poster="{{path_compat('')}}" height="100" width="100" ></video>
|
|
@@ -60,6 +60,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
|
|
|
editor.render("container");
|
|
|
</script>
|
|
|
<script type="text/javascript">
|
|
|
+
|
|
|
$('#video_upload').on('click', function() {
|
|
|
// 定义预签名URL
|
|
|
var signedUrl = '';
|
|
@@ -93,7 +94,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $(document).on('change','#form-upload-file',function(){
|
|
|
+ // 上传文件
|
|
|
+ $(document).off('change', '#form-upload-file').on('change','#form-upload-file',function(){
|
|
|
// 获取文件
|
|
|
const fileInput = document.getElementById('form-upload-file');
|
|
|
const file = fileInput.files[0];
|
|
@@ -102,10 +104,46 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
|
|
|
art.dialog({content: '请上传文件',lock: true,ok: function() {}});
|
|
|
return ;
|
|
|
}
|
|
|
- // 调用上传
|
|
|
- upload(file, signedUrl);
|
|
|
+ // // 如果没有上传文件
|
|
|
+ // if ( file.size >= 524288000 ) {
|
|
|
+ // art.dialog({content: '上传视频不允许大于500MB',lock: true,ok: function() {}});
|
|
|
+ // return ;
|
|
|
+ // }
|
|
|
+
|
|
|
+ const result = checkVideoResolution(file);
|
|
|
+ result.then(function($re){
|
|
|
+ if( !$re ){
|
|
|
+ art.dialog({content: '上传视频不允许大于1280*720',lock: true,ok: function() {}});
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ // 调用上传
|
|
|
+ upload(file, signedUrl);
|
|
|
+ });
|
|
|
+
|
|
|
+ return ;
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+ const checkVideoResolution = (file) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const video = document.createElement('video',{}); // 创建一个临时的video元素
|
|
|
+ const url = URL.createObjectURL(file); // 创建一个指向文件的URL
|
|
|
+ video.src = url; // 设置video元素的源为文件URL
|
|
|
+ video.muted = true; // 静音视频,避免自动播放问题
|
|
|
+ // 等待元数据加载完成
|
|
|
+ video.onloadedmetadata = function (){ // 等待元数据加载完成
|
|
|
+ URL.revokeObjectURL(url); // 释放URL对象
|
|
|
+ if (video.videoWidth > 1280 || video.videoHeight > 720) {
|
|
|
+ video.remove();
|
|
|
+ resolve(false);
|
|
|
+ } else {
|
|
|
+ video.remove();
|
|
|
+ resolve(true);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
const upload = async (file, presignedUrl) => {
|
|
|
// 提示上传中
|
|
|
art.dialog({id:'loading',lock: true,title:'视频上传中'});
|