1、时间进度:

  1. <style>
  2. *{
  3. margin: 0px;
  4. padding: 0px;
  5. }
  6. .video_player{
  7. position: relative;
  8. width: 1000px;
  9. height: 500px;
  10. margin: 0px auto;
  11. }
  12. video{
  13. position: absolute;
  14. width: 1000px;
  15. height: 500px;
  16. left: 0px;
  17. top: 0px;
  18. }
  19. .menu{
  20. position: absolute;
  21. width: 100%;
  22. height: 50px;
  23. background-color: rgba(0,0,0,0.5);
  24. bottom: 0px;
  25. display: none;
  26. }
  27. .play{
  28. position: absolute;
  29. width: 60px;
  30. height: 30px;
  31. border: 1px solid white;
  32. text-align: center;
  33. line-height: 30px;
  34. color: white;
  35. border-radius: 10px;
  36. margin-left: 20px;
  37. top: 50%;
  38. margin-top: -15px;
  39. cursor: pointer;
  40. }
  41. .time{
  42. position: absolute;
  43. width: 100px;
  44. height: 30px;
  45. text-align: center;
  46. line-height: 30px;
  47. color: white;
  48. border-radius: 10px;
  49. margin-left: 120px;
  50. top: 50%;
  51. margin-top: -15px;
  52. cursor: pointer;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <div class="video_player">
  58. <!--videoaudio是一样的,只比audio多一个视频,方法都一样 -->
  59. <video src="contenteditable.mov" controls></video><!-- controls才能有播放栏 -->
  60. <div class="menu">
  61. <div class="play">播放</div>
  62. <div class="time">000/000</div>
  63. </div>
  64. </div>
  65. <script>
  66. var videoPlayer = document.getElementsByClassName("video_player")[0];
  67. var video = videoPlayer.getElementsByTagName("video")[0];
  68. var menu = document.getElementsByClassName('menu')[0];
  69. var play = document.getElementsByClassName("play")[0];
  70. var time = document.getElementsByClassName("time")[0];
  71. videoPlayer.onmouseenter = function() {
  72. menu.style.display = "block";
  73. }
  74. videoPlayer.onmouseleave = function(){
  75. menu.style.display = "none";
  76. }
  77. play.onclick = function(){
  78. if(video.paused){
  79. video.play();
  80. play.innerHTML = "暂停";
  81. }else{
  82. video.pause();
  83. play.innerHTML = "播放";
  84. }
  85. }
  86. setInterval(function(){
  87. var total = video.duration;//一共的时间
  88. var nowtime = video.currentTime;//当前的时间
  89. time.innerHTML = parseInt(nowtime / 60) + ":" + parseInt(nowtime % 60) + "/" + parseInt(total / 60) + ":" + parseInt(total % 60) ;
  90. },1000)
  91. </script>
  92. </body>