feat(video-workspace): 新增本地上传视频按钮
This commit is contained in:
1 parent
179f6168ce
commit
6a10adc1d5
2 files changed
+35
-1
No files matched your search
@@ -3,6 +3,8 @@
|
||||
const stopBtn = document.getElementById('stopBtn');
|
||||
const clearBtn = document.getElementById('clearBtn');
|
||||
const pickCachedVideoBtn = document.getElementById('pickCachedVideoBtn');
|
||||
const uploadWorkVideoBtn = document.getElementById('uploadWorkVideoBtn');
|
||||
const workVideoFileInput = document.getElementById('workVideoFileInput');
|
||||
const cacheVideoModal = document.getElementById('cacheVideoModal');
|
||||
const closeCacheVideoModalBtn = document.getElementById('closeCacheVideoModalBtn');
|
||||
const cacheVideoList = document.getElementById('cacheVideoList');
|
||||
@@ -90,6 +92,7 @@
|
||||
let mergeTargetVideoName = '';
|
||||
let mergeCutMsA = 0;
|
||||
let mergeCutMsB = 0;
|
||||
let workVideoObjectUrl = '';
|
||||
|
||||
function buildHistoryTitle(type, serial) {
|
||||
const n = Math.max(1, parseInt(String(serial || '1'), 10) || 1);
|
||||
@@ -460,6 +463,13 @@
|
||||
mergeTargetVideoName = '';
|
||||
mergeCutMsA = 0;
|
||||
mergeCutMsB = 0;
|
||||
if (workVideoObjectUrl) {
|
||||
try { URL.revokeObjectURL(workVideoObjectUrl); } catch (e) { /* ignore */ }
|
||||
workVideoObjectUrl = '';
|
||||
}
|
||||
if (workVideoFileInput) {
|
||||
workVideoFileInput.value = '';
|
||||
}
|
||||
if (enterEditBtn) enterEditBtn.disabled = true;
|
||||
closeEditPanel();
|
||||
updateMergeLabels();
|
||||
@@ -2316,6 +2326,28 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (uploadWorkVideoBtn && workVideoFileInput) {
|
||||
uploadWorkVideoBtn.addEventListener('click', () => {
|
||||
workVideoFileInput.click();
|
||||
});
|
||||
workVideoFileInput.addEventListener('change', () => {
|
||||
const file = workVideoFileInput.files && workVideoFileInput.files[0];
|
||||
if (!file) return;
|
||||
if (workVideoObjectUrl) {
|
||||
try { URL.revokeObjectURL(workVideoObjectUrl); } catch (e) { /* ignore */ }
|
||||
workVideoObjectUrl = '';
|
||||
}
|
||||
const localUrl = URL.createObjectURL(file);
|
||||
workVideoObjectUrl = localUrl;
|
||||
selectedVideoItemId = `upload-${Date.now()}`;
|
||||
selectedVideoUrl = localUrl;
|
||||
if (enterEditBtn) enterEditBtn.disabled = false;
|
||||
bindEditVideoSource(localUrl);
|
||||
openEditPanel();
|
||||
toast('本地视频已载入工作区', 'success');
|
||||
});
|
||||
}
|
||||
|
||||
if (pickMergeVideoBtn) {
|
||||
pickMergeVideoBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
|
||||
@@ -139,6 +139,8 @@
|
||||
<div class="card-title">视频工作区</div>
|
||||
<div class="preview-actions">
|
||||
<button id="pickCachedVideoBtn" class="geist-button-outline text-xs px-3">选择视频</button>
|
||||
<button id="uploadWorkVideoBtn" class="geist-button-outline text-xs px-3" type="button">上传视频</button>
|
||||
<input id="workVideoFileInput" class="ref-file-input" type="file" accept="video/*">
|
||||
<button id="clearBtn" class="geist-button-outline text-xs px-3">清空</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -316,7 +318,7 @@
|
||||
<script src="/static/common/js/pwa.js?v=0.1.1"></script>
|
||||
<script src="/static/vendor/ffmpeg/ffmpeg.js?v=0.1.0"></script>
|
||||
<script src="/static/vendor/ffmpeg/ffmpeg-util.js?v=0.1.0"></script>
|
||||
<script src="/static/public/js/video.js?v=0.5.19"></script>
|
||||
<script src="/static/public/js/video.js?v=0.5.20"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user