视频标签:估计也就是自动播放,js换文件播放,这两种情况吧
autoplay="autoplay" 自动播放
loop=loop 循环播放
var file = document.getElementById('file').files[0];
var url = window.URL.createObjectURL(file) ; js获取文件路径
document.getElementById("my-video").src = url; 更换video 的source的src路径
var myVideo=document.getElementById("my-video");
myVideo.play(); video播放
<div class="mydiv">
<div style="padding:30px">
<input type="file" id="file" οnchange="onInputFileChange()">
<a οnclick="closemyDiv()">关闭</a>
</div>
</div>
<div class="panel-body">
<video id="my-video" controls="controls" autoplay="autoplay" preload="auto" loop="loop" width="525" height="240"
poster="m.png" >
<source src="/assets/screen/jq22-sp.mp4" type="video/mp4">
您的浏览器不支持 HTML5 video 标签。
</video>
</div>
function showChoice(){
$(".mydiv").show();
}
function onInputFileChange(){
var file = document.getElementById('file').files[0];
var url = window.URL.createObjectURL(file)
console.log(url);
document.getElementById("my-video").src = url;
var myVideo=document.getElementById("my-video");
myVideo.play();
closemyDiv();
}
function videoPlay(){
var myVideo=document.getElementById("my-video");
myVideo.play();
}
function closemyDiv(){
$(".mydiv").hide();
}
另外一个网上的自动播放
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<div style="text-align:center">
<button οnclick="playPause()">播放/暂停</button>
<button οnclick="makeBig()">放大</button>
<button οnclick="makeSmall()">缩小</button>
<button οnclick="makeNormal()">普通</button>
<button οnclick="changelj()">改变路径</button>
<input type="file" id="file" οnchange="onInputFileChange()">
<br>
<video id="video1" width="420">
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
您的浏览器不支持 HTML5 video 标签。
</video>
</div>
<script>
var myVideo=document.getElementById("video1");
function playPause()
{
if (myVideo.paused)
myVideo.play();
else
myVideo.pause();
}
function makeBig()
{
myVideo.width=560;
}
function makeSmall()
{
myVideo.width=320;
}
function makeNormal()
{
myVideo.width=420;
}
function changelj(){
document.getElementById("video1").src="video/3.mp4";
document.getElementById("media").load();
}
function onInputFileChange(){
var file = document.getElementById('file').files[0];
var url = URL.createObjectURL(file);
console.log(url);
var video = document.getElementById("video1").src=url;
//var myVideo=document.getElementById("video1");
//myVideo.play();
var myVideo=document.getElementById("video1");
myVideo.addEventListener('ended', function(){
play();
});
myVideo.play();
}
function play(){
var myVideo=document.getElementById("video1");
myVideo.play();
}
</script>
</body>
</html>