html5 video

视频标签:估计也就是自动播放,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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值