低配版播放器(播放本地视频)

1.html和javascript混合代码:本地直接打开即可。

<!DOCTYPE html>
<html>
  <head>
    <title>Local Video Player</title>
  </head>
  <body>
    <input type="file" id="inputVideo" accept="video/*">
    <video id="myVideo" controls>
      <source id="videoSource" type="video/mp4">
    </video>

    <script>
      const input = document.getElementById('inputVideo');
      const video = document.getElementById('myVideo');
      const source = document.getElementById('videoSource');

      input.addEventListener('change', function(event) {
        const file = this.files[0];
        const url = URL.createObjectURL(file);
        source.setAttribute('src', url);
        video.load();
      });
    </script>
  </body>
</html>

 

posted @ 2023-02-21 18:20  バカなの  阅读(32)  评论(0编辑  收藏  举报