效果:
代码很简单
js
define("html5_video_player", [ '../avalon-min'], function(avalon) { function formatTime(seconds) { var seconds = Math.round(seconds); var minutes = Math.floor(seconds / 60); seconds = Math.floor(seconds % 60); minutes = (minutes >= 10) ? minutes : "0" + minutes; seconds = (seconds >= 10) ? seconds : "0" + seconds; return minutes + ":" + seconds; } var playing=false,mute=false,vol=50,fs=false,active=false,inactivityTimeout=timer=null; avalon.bind($('control_btn'),'click',function(){ if(!playing){ $('html5_video').play(); $('control_btn').className='html5_video_pause_btn inline-block'; playing=true; }else{ $('html5_video').pause(); $('control_btn').className='html5_video_play_btn inline-block'; playing=false; } }); avalon.bind($('video_bar'),'click',function(e){ var a=(e.clientX-$('video_bar').offsetLeft)/$('video_bar').offsetWidth; $('html5_video').currentTime =a.toFixed(2)*$('html5_video').duration; }); avalon.bind($('vol_bar'),'click',function(e){ var a=(e.clientX-$('vol_bar').offsetLeft-8)/$('vol_bar').offsetWidth; vol=$('html5_video').volume =a; $('vol_value').style.width=a*100+'%'; }); avalon.bind($('mute_icon'),'click',function(){ if(!mute){ $('html5_video').volume=0; $('mute_icon').className='html5_video_mute1'; mute=true; }else{ $('html5_video').volume=vol; $('mute_icon').className='html5_video_mute'; mute=false; } }); avalon.bind($('html5_video'),'loadedmetadata',function(){ $('html5_video_duration').innerHTML=formatTime($('html5_video').duration); $('html5_video').volume=0; }); avalon.bind($('html5_video'),'timeupdate',function(){ $('html5_play_time').innerHTML=formatTime($('html5_video').currentTime); $('video_progress_bar').style.left=$('html5_video').currentTime/$('html5_video').duration*100+'%'; }); avalon.bind($('html5_video_fullscreen'),'click',function(e){ if(!fs){ toggle_fullscreen(); }else{ exit_fullscreen(); } }); document.onmozfullscreenchange = function() { if ($('html5_video').clientWidth +2!= document.documentElement.clientWidth) { exit_fullscreen(); } }; document.onwebkitfullscreenchange = function() { if ($('html5_video').clientWidth!= document.documentElement.clientWidth) { exit_fullscreen(); } }; function exit_fullscreen() { $('html5_video').className=''; fs = false; active=false; $('video_control').className=''; if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } } function toggle_fullscreen() { $('html5_video').className='video_fs'; fs = true; $('video_control').className='fullscreen'; var elem=$('html5_video'); if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(); } } function updateBuffered() { var v = $('html5_video'); var r = v.buffered; if (r) { for (var i=0; i<r.length; i++) { var start = r.start(i); var end = r.end(i); } $('video_buffer_bar').style.width=end/$('html5_video').duration*100+'%'; } } setInterval(updateBuffered,500); function b(){ if(active){ $('video_control').style.display='none'; active=false; console.log(active); } } avalon.bind($('html5_video'),'mousemove',function(e){ if(fs){ clearTimeout(inactivityTimeout); active=true; $('video_control').style.display='block'; inactivityTimeout = setTimeout(b, 5000); } }); });
html
<link type="text/css" href="http://localhost/twitter/css/html5_video_player.css" rel="stylesheet" /> <div id='wrap_html5_video'> <div id='html5_video_area'> <video id="html5_video" width="360" height="240"> <source type=" video/mp4" src="http://localhost/twitter/videos/2.mp4"></source> <source type=" video/webm" src="http://localhost/twitter/videos/2.webm"></source> </video> </div> <div id='video_control'> <div id='video_bar'> <div id='video_buffer_bar'></div> <div id='video_progress_bar'></div> </div> <div id='play_control'> <ul> <li class='inline-block'><a class='html5_video_play_btn inline-block' id='control_btn'></a></li> <li class='inline-block'><a id='mute_icon' class='html5_video_mute'></a> <div id='vol_bar' class='inline-block'> <p id='vol_value'></p> </div></li> <li class='inline-block' id='html5_video_time'><span id='html5_play_time'>00:00</span><span>/</span><span id='html5_video_duration'>33:44</span></li> <li class='inline-block'><a id='html5_video_fullscreen' class='inline-block'></a></li> </ul> </div> <div id='a'></div> </div> <div id='buffered_log'></div> </div> <script type="text/javascript"> require('html5/html5_video_player'); </script>
css
@CHARSET "UTF-8"; #wrap_html5_video { padding: 10px; width: 360px; } #vol_bar,#video_bar,#vol_value { height: 9px; background-color: #999999; } #vol_bar { width: 100px; cursor: pointer; } #vol_value { background-color: #179df7; width: 50%; } #html5_video { display: block; border: 1px solid #c0deed; } #video_buffer_bar { background-color: #179DF7; width: 0; } #video_progress_bar,#video_buffer_bar { position: absolute; height: 100%; } #video_progress_bar { background-color: #0066FF; width: 2px; left: 0; } .html5_video_pause_btn,.html5_video_play_btn { width: 40px; height: 40px; cursor: pointer; } .html5_video_play_btn { background: url("http://localhost/twitter/images/html5_video.jpg") 0 0 no-repeat; } .html5_video_play_btn:hover { background: url("http://localhost/twitter/images/html5_video.jpg") -41px 0 no-repeat; } .html5_video_pause_btn { background: url("http://localhost/twitter/images/html5_video.jpg") 0 -42px no-repeat; } .html5_video_pause_btn:hover { background: url("http://localhost/twitter/images/html5_video.jpg") -41px -42px no-repeat; } #play_control a,#vol_bar { vertical-align: middle; } #html5_video_fullscreen { width: 25px; background: url("http://localhost/twitter/images/html5_video.jpg") 0 -310px no-repeat; height: 18px; } #play_control #html5_video_time { font-size: 14px; } #play_control li,#play_control ul { font-size: 0; } #play_control li:last-child { position: absolute; right: 0; } .html5_video_mute1 { background: url("http://localhost/twitter/images/html5_video.jpg") no-repeat scroll -79px -170px rgba(0, 0, 0, 0); } .html5_video_mute { background: url("http://localhost/twitter/images/html5_video.jpg") no-repeat scroll 0 -170px rgba(0, 0, 0, 0); } #mute_icon { cursor: pointer; display: inline-block; height: 15px; width: 18px; } .html5_video_mute:hover { background: url("http://localhost/twitter/images/html5_video.jpg") -19px -170px no-repeat; } #play_control li { height: 40px; vertical-align: top; margin: 0 5px; } #play_control li:after { display: inline-block; width: 0; height: 100%; vertical-align: middle; content: ''; } #play_control,#video_bar,#vol_bar { position: relative; } body .fullscreen { position: fixed; left: 0; bottom: 0; width: 100%; overflow: hidden; z-index: 2147483647; background-color: #fff; } video::-webkit-media-controls { display: none !important; }

JavaScript在现实世界中的应用包括服务器端编程、移动应用开发和物联网控制:1.通过Node.js实现服务器端编程,适用于高并发请求处理。2.通过ReactNative进行移动应用开发,支持跨平台部署。3.通过Johnny-Five库用于物联网设备控制,适用于硬件交互。

我使用您的日常技术工具构建了功能性的多租户SaaS应用程序(一个Edtech应用程序),您可以做同样的事情。 首先,什么是多租户SaaS应用程序? 多租户SaaS应用程序可让您从唱歌中为多个客户提供服务

本文展示了与许可证确保的后端的前端集成,并使用Next.js构建功能性Edtech SaaS应用程序。 前端获取用户权限以控制UI的可见性并确保API要求遵守角色库

JavaScript是现代Web开发的核心语言,因其多样性和灵活性而广泛应用。1)前端开发:通过DOM操作和现代框架(如React、Vue.js、Angular)构建动态网页和单页面应用。2)服务器端开发:Node.js利用非阻塞I/O模型处理高并发和实时应用。3)移动和桌面应用开发:通过ReactNative和Electron实现跨平台开发,提高开发效率。

JavaScript的最新趋势包括TypeScript的崛起、现代框架和库的流行以及WebAssembly的应用。未来前景涵盖更强大的类型系统、服务器端JavaScript的发展、人工智能和机器学习的扩展以及物联网和边缘计算的潜力。

JavaScript是现代Web开发的基石,它的主要功能包括事件驱动编程、动态内容生成和异步编程。1)事件驱动编程允许网页根据用户操作动态变化。2)动态内容生成使得页面内容可以根据条件调整。3)异步编程确保用户界面不被阻塞。JavaScript广泛应用于网页交互、单页面应用和服务器端开发,极大地提升了用户体验和跨平台开发的灵活性。

Python更适合数据科学和机器学习,JavaScript更适合前端和全栈开发。 1.Python以简洁语法和丰富库生态着称,适用于数据分析和Web开发。 2.JavaScript是前端开发核心,Node.js支持服务器端编程,适用于全栈开发。

JavaScript不需要安装,因为它已内置于现代浏览器中。你只需文本编辑器和浏览器即可开始使用。1)在浏览器环境中,通过标签嵌入HTML文件中运行。2)在Node.js环境中,下载并安装Node.js后,通过命令行运行JavaScript文件。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

记事本++7.3.1
好用且免费的代码编辑器

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

SublimeText3 Linux新版
SublimeText3 Linux最新版