一个html5播放视频的video控件只支持android的默认格式mp4和3gp
2023-06-13 09:15:26 时间
<!DOCTYPEhtml>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title></title>
</head>
<body>
<divid="divVideo"></div>
//因js水平有限,不喜勿喷,全当没事看看,video是html5中的新控件,大家可以看看
<scripttype="text/javascript">
//mp4是ios、android普遍支持的格式
functionplayVideo(opt){
if(typeof(opt)=="undefined"){
alert("请传入必要参数!");
return;
}
if(typeof(opt.elemt)=="undefined"){
alert("请指定播放器要插入的对象!");
return;
}
if(typeof(opt.src)=="undefined"){
alert("请指定要播放视频的路径!");
return;
}
var_this=this;
_this.elemt=opt.elemt;//播放器要插入的对象
_this.src=opt.src;//视频的URL(必设)
_this.width=opt.width>0?opt.width+"px":"100%";//宽度(默认100%)
_this.height=opt.height>0?opt.height+"px":"100%";//高度(默认100%)
_this.autoplay=opt.autoplay=="true"?"autoplay":"";//自动播放(true为自动播放)
_this.poster=opt.poster;//视频封面,播放时的封面图片
_this.preload=opt.preload=="true"?"preload":"";//预加载(true时启动加载)
_this.loop=opt.loop=="true"?"loop":"";//循环播放(true时循环播放)
varstr="<videoid="playVideo"controls";//根据设置的属性的值,拼写video控件
str+="width=""+_this.width+""height=""+_this.height+"""+_this.autoplay+""+_this.preload+""+_this.loop+"";
if(typeof(_this.poster)!="undefined"){
str+="poster=""+_this.poster+"">";
}else{
str+=">";
}
str+="<sourcesrc=""+_this.src+""/>";
str+="</video>";
this.elemt.innerHTML=str;//将str放到要插入的对象中
}
playVideo({
//所有参数,elemt和src为必填其他看需求怎么要求
//elemt为播放控件要插入的容器,src为视频文件地址,preload为预加载,autoplay是否页面进入就自动播放
//poster为播放前的遮照图片,loop为是否循环播放,width和heigth默认100%
elemt:document.getElementById("divVideo"),
src:"3.mp4",
preload:"true",
autoplay:"true",
poster:"",
loop:"true",
width:"",
heigth:""
});
</script>
</body>
</html>
相关文章
- android 浏览器 开发,Android 浏览器的开发实例分享
- android activity自动跳转,Android activity跳转之finish()方法的作用
- android签名命令行,Android系统签名位置及命令
- android okio使用方法,Android 开源框架 Okio 原理剖析「建议收藏」
- Android LitePal数据库
- android进阶之了解Android系统与开机过程
- Android SDK下载失败解决[通俗易懂]
- delphixe5 android,Delphi XE5 Android手机端转换Ansi字符串
- android .dex文件探究
- android toast显示时间,Android Toast自定义显示时间「建议收藏」
- android toast 自定义时间,Android 自定义 Toast 显示时间「建议收藏」
- Android resource linking failed_android sdk location should not
- eclipse中android开发_Android开发教程
- android 复制控件,Android长按复制文本功能[通俗易懂]
- android进程间通信的方式_Android进程注入
- android线程间通信的几种方法_Android进程间和线程间通信方式
- Mac下安装NDK(android开发)
- android intent打开各种格式文档方法
- Android进程间通信与逆向分析
- 【Android 逆向】Android 中常用的 so 动态库 ( 拷贝 /system/lib/ 中的 Android 系统 so 动态库 )
- 【错误记录】Android 应用安装后出现两个启动图标 ( 排查应用及依赖库中配置了 android.intent.category.LAUNCHER 的 Activity )
- 【ijkplayer】编译 Android 版本的 ijkplayer ⑥ ( 进入 ijkplayer-android/android 目录 | 执行 compile-ijk.sh 脚本完成编译 )
- [android] 界面切换的核心方法详解手机开发
- Android热修复Tinker接入实战详解手机开发
- Android中实现多Tab页应用
- android实现圆角图片解决方案
- Android启动模拟器报错解决方法
- Android系统自带样式(android:theme)