这是我的代码示例。
$("#videoSubmit").click(function() {
var video = document.createElement("video");
video.setAttribute("controls", "");
var source = document.createElement("source");
source.src = URL.createObjectURL(document.querySelector('input[id=file_v]').files[0]);
alert(source.src);
$(video).append(source);
$("#post").append(video);
$("#vid").hide();
});
$("#video").click(function() {
$("#vid").show();
});

div[contenteditable] {
padding: 10px;
border: 1px solid #555555;
background-color: #ffffff;
min-height: 50px;
width: 500px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="video" class="bar">Insert Video</button>
<form action='Post' method='post'>
<div contenteditable="true" id='post'></div><br>
<!--input type='submit'/-->
</form>
<fieldset style="background: beige; position: absolute; z-index: 10; top: 300px; left: 300px;" id="vid" hidden>
<h2>Insert Video</h2><input type="file" id="file_v" /><button id="videoSubmit">Add Video</button></fieldset>
&#13;
我想插入视频的预览,稍后我将使用java进行处理。它适用于除* .avi文件之外的每个文件扩展名。提前致谢