HTML
<button οnclick="playPause()" id="button1">播放</button>
<button οnclick="makeBig()">放大</button>
<button οnclick="makeSmall()">缩小</button>
<button οnclick="makeNormal()">普通</button>
<button οnclick="goBack(5);">快进</button>
<button οnclick="goBack(-5);">快退</button>
<button οnclick="volume(0.1);">音量+</button>
<button οnclick="volume(-0.1);">音量-</button>
<button id="Mute" οnclick="Mute();">静音</button>
<button οnclick="setplay()">倍速播放</button>
<button οnclick="settime()">重新开始</button>
<input id="D_file" type="file" style="display: none;" οnchange="selectImage(this)"/>
<button id="play" οnclick="chang1()">请选择文件导入</button>
js获取
<script src="jquery-1.11.1.min.js"></script>
<script>
var myVideo=document.getElementById("video1");
function playPause()
{
var button1=document.getElementById("button1")
if (myVideo.paused) {
myVideo.play();
button1.innerHTML="暂停";
}
else {
myVideo.pause();
button1.innerHTML="播放";
}
}
function makeBig()
{
myVideo.width=1000;
}
function makeSmall()
{
myVideo.width=560;
}
function makeNormal()
{
myVideo.width=800;
}
//控制快进/快退的方法
function goBack(val){
myVideo.currentTime += val;
}
//控制音量的方法
function volume(val){
myVideo.volume+=val;
}
//播放声音与静音模式
function Mute(){
var imButton=document.getElementById("Mute");
if (myVideo.muted){
myVideo.muted=false;
imButton.innerHTML="静音模式";
}
else{
myVideo.muted=true;
imButton.innerHTML="播放声音";
}
}
function setplay(){
if(myVideo.playbackRate){
myVideo.playbackRate = 2;
}else{
myVideo.playbackRate = 1;
}
}
//设置视频重新播放 设置时间到0开始
function settime(){
myVideo.currentTime=0;
}
//file函数定义文件导入
function chang1(){
var D_file=document.getElementById('D_file');
D_file.click();
}
function play(){
var file = document.getElementById('D_file').files[0];
var url = URL.createObjectURL(file);
console.log(url);
document.getElementById("video_id").src = url;
}
var image = '';
function selectImage(file) {
if (!file.files || !file.files[0]) {
return;
}
var reader = new FileReader();
reader.onload = function (evt) {
document.getElementById('video1').src = evt.target.result;
image = evt.target.result;
}
reader.readAsDataURL(file.files[0]);
}
</script>