【发布时间】:2021-02-16 10:11:03
【问题描述】:
我怎么可能添加 .mp4 或 .webm 的扩展名?它只会产生这样的效果
HTML
<input type="file" name="file[]" id="inpVid" accept="video/*">
<video style="width: 100%; max-width: 100%; margin-bottom: 10px;" controls id="vidURL">
<source id="videoUrl" src="#" type="video/mp4">
</video>
脚本
<script>
function changeVideoURL (element) {
const videoURLElement = document.getElementById('videoUrl')
const videoPlayer = document.getElementById('vidURL')
if (element.files && element.files[0]) {
videoURLElement.src = URL.createObjectURL(element.files[0]);
videoPlayer.load()
}
}
document.getElementById("inpVid").onchange = function() {
changeVideoURL(this)
}
</script>
【问题讨论】:
-
你想要的是
accept=".webm,.mp4"吗? -
我放了这个。不工作。
标签: javascript html html5-video