1、简易播放器:

  1. 控制条的实现:
  2. <style>
  3. *{
  4. margin: 0px;
  5. padding: 0px;
  6. }
  7. .video_player{
  8. position: relative;
  9. width: 1000px;
  10. height: 500px;
  11. margin: 0px auto;
  12. }
  13. video{
  14. position: absolute;
  15. width: 1000px;
  16. height: 500px;
  17. left: 0px;
  18. top: 0px;
  19. }
  20. .menu{
  21. position: absolute;
  22. width: 100%;
  23. height: 50px;
  24. background-color: rgba(0,0,0,0.5);
  25. bottom: 0px;
  26. display: none;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div class="video_player">
  32. <!--videoaudio是一样的,只比audio多一个视频,方法都一样 -->
  33. <video src="contenteditable.mov" controls></video><!-- controls才能有播放栏 -->
  34. <div class="menu"></div>
  35. </div>
  36. <script>
  37. var videoPlayer = document.getElementsByClassName("video_player")[0];
  38. var menu = document.getElementsByClassName('menu')[0];
  39. videoPlayer.onmouseenter = function() {
  40. menu.style.display = "block";
  41. }
  42. videoPlayer.onmouseleave = function(){
  43. menu.style.display = "none";
  44. }
  45. </script>
  46. </body>