本地视频播放网页

[复制链接]
101 |10
发表于 前天 05:45 | 显示全部楼层 |阅读模式
公司需要很多人落实监控违章情况,由监控室落实好视频并编号存储成MP4文件,和表格文件,表格文件中视频文件的名字,然后打包发到工作群里,然后由各组长对本组问题进行落实,大家每次都登录微信到电脑上然后下载在找到自己负责的视频编号,有的电脑上播放器还有广告,给大家工作带来了很多麻烦,根据这个情况,我写了个小网页,方便大家使用,目前大家感觉很好用,分享出来,看有没有人也能用到。





   
   
    河口监控落实辅助工具
   
        /* 基础样式 */
        body {
            font-family: 'Arial', sans-serif;
            line-height: 1.6;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
            color: #333333;
        }

        /* 标题和输入框区域 */
        h1 {
            color: #0056b3;
            text-align: center;
            margin-bottom: 30px;
        }

        .container {
            max-width: 100%;
            margin: 0 auto;
        }

        .input-container {
            background: #ffffff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }

        input[type="text"] {
            width: calc(100% - 100px); /* 为按钮留出空间 */
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
            margin-bottom: 10px;
        }

        button {
            padding: 8px 16px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }

        /* 视频列表 */
        #video-list {
            list-style-type: none;
            padding: 0;
            margin: 0;
        }

        #video-list li {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: #ffffff;
            margin-top: 10px;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        /* 视频播放器 */
        #video-player {
            width: 100%; /* 占满容器宽度 */
            height: auto; /* 自动调整高度 */
            margin: 20px 0;
            background: #000000;
            border-radius: 4px;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .input-container {
                padding: 15px;
            }

            input[type="text"] {
                width: calc(100% - 100px); /* 适应按钮大小 */
            }

            button {
                width: 100%;
                margin-top: 10px;
            }

            #video-player {
                width: 100%; /* 在小屏幕上占满宽度 */
                height: auto; /* 自动调整高度 */
            }
        }
   
        

// 禁止右键菜单
document.oncontextmenu = function() { return false; }

// 禁止Ctrl+U查看源码
document.onkeydown = function(e) {
  if (e.ctrlKey && (e.keyCode === 85 || e.keyCode === 117)) { // 阻止Ctrl+U
    return false;
  }
  if (e.keyCode === 123) { // 阻止F12
    return false;
  }
}



/* 禁止文本选择 */
body {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* 隐藏视频真实路径 */
#video-player source {
  display: none !important;
}



   
        河口监控落实工具
        
        
            请按照监控代码输入文件名(省略.mp4):
            
            查找
        

        

        
   

   
        let videoListItems = []; // 存储视频列表项

        const videoList = document.getElementById('video-list');
        const videoPlayer = document.getElementById('video-player');

        function addVideoToList(fileName) {
            const listItem = document.createElement('li');
            listItem.textContent = fileName + '.mp4';

            // 添加播放按钮
            const playButton = document.createElement('button');
            playButton.textContent = '播放';
            playButton.addEventListener('click', () => {
                videoPlayer.src = `videos/${fileName}.mp4`;
                videoPlayer.load();
                videoPlayer.play();
            });

            listItem.appendChild(playButton);
            videoList.appendChild(listItem);
            videoListItems.push(listItem); // 存储以备清除
        }

        function addVideos() {
            // 清空当前列表
            videoListItems.forEach(item => videoList.removeChild(item));
            videoListItems = [];

            const input = document.getElementById('video-input').value.trim();
            const fileNames = input ? input.split(',') : [];

            fileNames.forEach(fileName => {
                const trimmedFileName = fileName.trim();
                if (trimmedFileName) {
                    addVideoToList(trimmedFileName);
                }
            });
        }
   


使用方法:建立一个文本文档把以上内容复制进去,改后缀名为html,然后在新建一个空文件夹“videos”里面放你需要播放的视频文件,用小皮简单设置一下网页目录就可以使用了。




本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

发表于 前天 05:45 | 显示全部楼层
发帖的时候选择代码块包一下。

[HTML]  
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>河口监控落实辅助工具</title>
  7.     <style>
  8.         /* 基础样式 */
  9.         body {
  10.             font-family: 'Arial', sans-serif;
  11.             line-height: 1.6;
  12.             margin: 0;
  13.             padding: 20px;
  14.             background-color: #f4f4f4;
  15.             color: #333333;
  16.         }
  17.         /* 标题和输入框区域 */
  18.         h1 {
  19.             color: #0056b3;
  20.             text-align: center;
  21.             margin-bottom: 30px;
  22.         }
  23.         .container {
  24.             max-width: 100%;
  25.             margin: 0 auto;
  26.         }
  27.         .input-container {
  28.             background: #ffffff;
  29.             padding: 20px;
  30.             border-radius: 8px;
  31.             box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  32.             margin-bottom: 20px;
  33.         }
  34.         label {
  35.             display: block;
  36.             margin-bottom: 5px;
  37.             font-weight: bold;
  38.         }
  39.         input[type="text"] {
  40.             width: calc(100% - 100px); /* 为按钮留出空间 */
  41.             padding: 8px;
  42.             border: 1px solid #ddd;
  43.             border-radius: 4px;
  44.             margin-bottom: 10px;
  45.         }
  46.         button {
  47.             padding: 8px 16px;
  48.             background-color: #007bff;
  49.             color: white;
  50.             border: none;
  51.             border-radius: 4px;
  52.             cursor: pointer;
  53.         }
  54.         button:hover {
  55.             background-color: #0056b3;
  56.         }
  57.         /* 视频列表 */
  58.         #video-list {
  59.             list-style-type: none;
  60.             padding: 0;
  61.             margin: 0;
  62.         }
  63.         #video-list li {
  64.             display: flex;
  65.             align-items: center;
  66.             justify-content: space-between;
  67.             background: #ffffff;
  68.             margin-top: 10px;
  69.             padding: 10px;
  70.             border: 1px solid #ddd;
  71.             border-radius: 4px;
  72.         }
  73.         /* 视频播放器 */
  74.         #video-player {
  75.             width: 100%; /* 占满容器宽度 */
  76.             height: auto; /* 自动调整高度 */
  77.             margin: 20px 0;
  78.             background: #000000;
  79.             border-radius: 4px;
  80.         }
  81.         /* 响应式设计 */
  82.         [url=home.php?mod=space&uid=945662]@media[/url] (max-width: 768px) {
  83.             .input-container {
  84.                 padding: 15px;
  85.             }
  86.             input[type="text"] {
  87.                 width: calc(100% - 100px); /* 适应按钮大小 */
  88.             }
  89.             button {
  90.                 width: 100%;
  91.                 margin-top: 10px;
  92.             }
  93.             #video-player {
  94.                 width: 100%; /* 在小屏幕上占满宽度 */
  95.                 height: auto; /* 自动调整高度 */
  96.             }
  97.         }
  98.     </style>
  99.         <!-- 在原HTML的<head>标签内添加 -->
  100. <script>
  101. // 禁止右键菜单
  102. document.oncontextmenu = function() { return false; }
  103. // 禁止Ctrl+U查看源码
  104. document.onkeydown = function(e) {
  105.   if (e.ctrlKey && (e.keyCode === 85 || e.keyCode === 117)) { // 阻止Ctrl+U
  106.     return false;
  107.   }
  108.   if (e.keyCode === 123) { // 阻止F12
  109.     return false;
  110.   }
  111. }
  112. </script>
  113. <style>
  114. /* 禁止文本选择 */
  115. body {
  116.   user-select: none;
  117.   -webkit-user-select: none;
  118.   -moz-user-select: none;
  119.   -ms-user-select: none;
  120. }
  121. /* 隐藏视频真实路径 */
  122. #video-player source {
  123.   display: none !important;
  124. }
  125. </style>
  126. </head>
  127. <body>
  128.     <div class="container">
  129.         <h1>河口监控落实工具</h1>
  130.         
  131.         <div class="input-container">
  132.             <label for="video-input">请按照监控代码输入文件名(省略.mp4):</label>
  133.             <input type="text" id="video-input" placeholder="例如: 021101,021102,021103">
  134.             <button>查找</button>
  135.         </div>
  136.         <ul id="video-list"></ul>
  137.         <video id="video-player" controls></video>
  138.     </div>
  139.     <script>
  140.         let videoListItems = []; // 存储视频列表项
  141.         const videoList = document.getElementById('video-list');
  142.         const videoPlayer = document.getElementById('video-player');
  143.         function addVideoToList(fileName) {
  144.             const listItem = document.createElement('li');
  145.             listItem.textContent = fileName + '.mp4';
  146.             // 添加播放按钮
  147.             const playButton = document.createElement('button');
  148.             playButton.textContent = '播放';
  149.             playButton.addEventListener('click', () => {
  150.                 videoPlayer.src = `videos/${fileName}.mp4`;
  151.                 videoPlayer.load();
  152.                 videoPlayer.play();
  153.             });
  154.             listItem.appendChild(playButton);
  155.             videoList.appendChild(listItem);
  156.             videoListItems.push(listItem); // 存储以备清除
  157.         }
  158.         function addVideos() {
  159.             // 清空当前列表
  160.             videoListItems.forEach(item => videoList.removeChild(item));
  161.             videoListItems = [];
  162.             const input = document.getElementById('video-input').value.trim();
  163.             const fileNames = input ? input.split(',') : [];
  164.             fileNames.forEach(fileName => {
  165.                 const trimmedFileName = fileName.trim();
  166.                 if (trimmedFileName) {
  167.                     addVideoToList(trimmedFileName);
  168.                 }
  169.             });
  170.         }
  171.     </script>
  172. </body>
  173. </html>
复制代码
回复

使用道具 举报

发表于 前天 05:46 | 显示全部楼层
[HTML]  
  1. <!DOCTYPE html>
  2. <html lang="zh-CN"> <!-- 修正语言为中文,更符合“河口监控”场景 -->
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>河口监控落实辅助工具</title>
  7.     <style>
  8.         /* 基础样式优化:统一间距、增强可读性 */
  9.         body {
  10.             font-family: 'Microsoft YaHei', Arial, sans-serif; /* 适配中文字体 */
  11.             line-height: 1.8;
  12.             margin: 0;
  13.             padding: 20px;
  14.             background-color: #f8f9fa;
  15.             color: #333;
  16.             user-select: none; /* 保留禁止文本选择,但仅作为基础体验优化 */
  17.             -webkit-user-select: none;
  18.             -moz-user-select: none;
  19.             -ms-user-select: none;
  20.         }
  21.         /* 标题样式优化:增加底部边框分隔 */
  22.         h1 {
  23.             color: #0056b3;
  24.             text-align: center;
  25.             margin: 0 0 30px;
  26.             padding-bottom: 15px;
  27.             border-bottom: 2px solid #e9ecef;
  28.         }
  29.         .container {
  30.             max-width: 1200px; /* 限制最大宽度,避免大屏下内容过宽 */
  31.             margin: 0 auto;
  32.         }
  33.         /* 输入区域优化:增加内边距、优化按钮布局 */
  34.         .input-container {
  35.             background: #fff;
  36.             padding: 25px;
  37.             border-radius: 8px;
  38.             box-shadow: 0 2px 8px rgba(0,0,0,0.08); /* 弱化阴影,更显清爽 */
  39.             margin-bottom: 25px;
  40.             display: flex;
  41.             flex-wrap: wrap; /* 支持换行,适配小屏幕 */
  42.             gap: 10px; /* 统一元素间距 */
  43.             align-items: center;
  44.         }
  45.         label {
  46.             display: block;
  47.             margin-bottom: 5px;
  48.             font-weight: 600;
  49.             color: #495057;
  50.         }
  51.         .input-group {
  52.             flex: 1; /* 让输入框占满剩余空间 */
  53.             min-width: 200px; /* 小屏幕下输入框最小宽度 */
  54.         }
  55.         input[type="text"] {
  56.             width: 100%; /* 改为100%,通过父容器控制宽度 */
  57.             padding: 10px 12px;
  58.             border: 1px solid #ced4da;
  59.             border-radius: 4px;
  60.             font-size: 14px;
  61.             transition: border-color 0.3s; /* 增加边框过渡效果 */
  62.         }
  63.         input[type="text"]:focus {
  64.             outline: none;
  65.             border-color: #80bdff; /* 聚焦时边框变色,提升交互感 */
  66.             box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
  67.         }
  68.         /* 按钮样式统一:增加不同状态颜色 */
  69.         button {
  70.             padding: 10px 20px;
  71.             border: none;
  72.             border-radius: 4px;
  73.             cursor: pointer;
  74.             font-size: 14px;
  75.             transition: background-color 0.3s;
  76.         }
  77.         .btn-find {
  78.             background-color: #007bff;
  79.             color: white;
  80.         }
  81.         .btn-find:hover {
  82.             background-color: #0056b3;
  83.         }
  84.         .btn-clear {
  85.             background-color: #6c757d;
  86.             color: white;
  87.         }
  88.         .btn-clear:hover {
  89.             background-color: #5a6268;
  90.         }
  91.         .btn-play {
  92.             background-color: #28a745;
  93.             color: white;
  94.         }
  95.         .btn-play:hover {
  96.             background-color: #218838;
  97.         }
  98.         /* 视频列表优化:增加hover效果,统一间距 */
  99.         #video-list {
  100.             list-style-type: none;
  101.             padding: 0;
  102.             margin: 0 0 30px;
  103.         }
  104.         #video-list li {
  105.             display: flex;
  106.             align-items: center;
  107.             justify-content: space-between;
  108.             background: #fff;
  109.             margin-top: 10px;
  110.             padding: 12px 15px;
  111.             border: 1px solid #e9ecef;
  112.             border-radius: 4px;
  113.             transition: background-color 0.3s;
  114.         }
  115.         #video-list li:hover {
  116.             background-color: #f8f9fa; /* hover时背景变色,提升交互感 */
  117.         }
  118.         /* 视频播放器优化:固定比例,避免拉伸 */
  119.         .video-wrapper {
  120.             position: relative;
  121.             width: 100%;
  122.             padding-top: 56.25%; /* 16:9比例(高度/宽度=9/16=0.5625) */
  123.             background: #000;
  124.             border-radius: 4px;
  125.             overflow: hidden;
  126.         }
  127.         #video-player {
  128.             position: absolute;
  129.             top: 0;
  130.             left: 0;
  131.             width: 100%;
  132.             height: 100%;
  133.         }
  134.         /* 响应式优化:小屏幕下输入区域垂直排列 */
  135.         [url=home.php?mod=space&uid=945662]@media[/url] (max-width: 768px) {
  136.             .input-container {
  137.                 flex-direction: column;
  138.                 align-items: stretch; /* 子元素占满宽度 */
  139.                 padding: 15px;
  140.             }
  141.             .input-group {
  142.                 width: 100%;
  143.                 margin-bottom: 10px;
  144.             }
  145.             /* 小屏幕下按钮独占一行,宽度100% */
  146.             .btn-group {
  147.                 width: 100%;
  148.                 display: flex;
  149.                 gap: 10px;
  150.             }
  151.             button {
  152.                 flex: 1; /* 按钮平分宽度 */
  153.             }
  154.         }
  155.         /* 提示文本样式 */
  156.         .tip-text {
  157.             font-size: 12px;
  158.             color: #6c757d;
  159.             margin-top: 5px;
  160.         }
  161.         /* 错误提示样式 */
  162.         .error-text {
  163.             color: #dc3545;
  164.             font-size: 14px;
  165.             margin-top: 10px;
  166.             text-align: center;
  167.             display: none; /* 默认隐藏 */
  168.         }
  169.     </style>
  170. </head>
  171. <body>
  172.     <div class="container">
  173.         <h1>河口监控落实工具</h1>
  174.         
  175.         <div class="input-container">
  176.             <div class="input-group">
  177.                 <label for="video-input">请输入监控代码(省略.mp4):</label>
  178.                 <input type="text" id="video-input" placeholder="例如:021101,021102,021103">
  179.                 <div class="tip-text">支持多个代码,用英文逗号分隔;仅支持.mp4格式视频</div>
  180.             </div>
  181.             <div class="btn-group">
  182.                 <button class="btn-find" id="find-btn">查找</button>
  183.                 <button class="btn-clear" id="clear-btn">清空列表</button>
  184.             </div>
  185.         </div>
  186.         <!-- 错误提示区域 -->
  187.         <div class="error-text" id="error-text"></div>
  188.         <!-- 视频列表 -->
  189.         <ul id="video-list"></ul>
  190.         <!-- 视频播放器(用容器固定比例) -->
  191.         <div class="video-wrapper">
  192.             <video id="video-player" controls preload="none">
  193.                 <!-- preload="none":默认不加载视频,优化性能 -->
  194.                 您的浏览器不支持HTML5视频播放,请升级浏览器后重试。
  195.             </video>
  196.         </div>
  197.     </div>
  198.     <script>
  199.         // 核心变量:存储视频列表项、错误提示元素
  200.         const videoList = document.getElementById('video-list');
  201.         const videoPlayer = document.getElementById('video-player');
  202.         const videoInput = document.getElementById('video-input');
  203.         const findBtn = document.getElementById('find-btn');
  204.         const clearBtn = document.getElementById('clear-btn');
  205.         const errorText = document.getElementById('error-text');
  206.         let videoListItems = []; // 存储已添加的列表项,用于清空
  207.         // 1. 添加视频到列表(增加合法性校验)
  208.         function addVideoToList(fileName) {
  209.             // 校验文件名:仅允许数字(监控代码通常为数字)
  210.             const reg = /^[0-9]+$/;
  211.             if (!reg.test(fileName)) {
  212.                 showError(`监控代码“${fileName}”无效,仅支持数字!`);
  213.                 return;
  214.             }
  215.             // 创建列表项
  216.             const listItem = document.createElement('li');
  217.             listItem.textContent = `${fileName}.mp4`;
  218.             // 创建播放按钮
  219.             const playButton = document.createElement('button');
  220.             playButton.className = 'btn-play';
  221.             playButton.textContent = '播放';
  222.             playButton.addEventListener('click', () => {
  223.                 // 隐藏错误提示
  224.                 hideError();
  225.                 // 设置视频路径并播放(增加加载失败处理)
  226.                 const videoUrl = `videos/${fileName}.mp4`;
  227.                 videoPlayer.src = videoUrl;
  228.                 videoPlayer.load();
  229.                
  230.                 // 监听视频加载失败事件
  231.                 videoPlayer.onerror = function() {
  232.                     showError(`视频“${fileName}.mp4”加载失败,请检查代码是否正确!`);
  233.                     videoPlayer.src = ''; // 清空无效路径
  234.                 };
  235.                 videoPlayer.play().catch(err => {
  236.                     // 处理自动播放失败(部分浏览器禁止自动播放)
  237.                     showError('视频自动播放失败,请点击播放器的“播放”按钮重试!');
  238.                 });
  239.             });
  240.             listItem.appendChild(playButton);
  241.             videoList.appendChild(listItem);
  242.             videoListItems.push(listItem);
  243.         }
  244.         // 2. 批量添加视频(处理输入框内容)
  245.         function addVideos() {
  246.             // 清空现有列表和错误提示
  247.             clearVideoList();
  248.             hideError();
  249.             // 获取并处理输入内容(去重、去空)
  250.             const input = videoInput.value.trim();
  251.             if (!input) {
  252.                 showError('请输入监控代码后再点击查找!');
  253.                 return;
  254.             }
  255.             // 分割输入(支持英文逗号,处理可能的空格)
  256.             let fileNames = input.split(',').map(name => name.trim());
  257.             // 去重(避免重复添加同一视频)
  258.             fileNames = [...new Set(fileNames)].filter(name => name);
  259.             if (fileNames.length === 0) {
  260.                 showError('请输入有效的监控代码(多个代码用英文逗号分隔)!');
  261.                 return;
  262.             }
  263.             // 批量添加视频
  264.             fileNames.forEach(fileName => addVideoToList(fileName));
  265.         }
  266.         // 3. 清空视频列表
  267.         function clearVideoList() {
  268.             videoListItems.forEach(item => videoList.removeChild(item));
  269.             videoListItems = [];
  270.             // 停止视频播放并清空路径
  271.             videoPlayer.pause();
  272.             videoPlayer.src = '';
  273.             hideError();
  274.         }
  275.         // 4. 显示错误提示
  276.         function showError(msg) {
  277.             errorText.textContent = msg;
  278.             errorText.style.display = 'block';
  279.         }
  280.         // 5. 隐藏错误提示
  281.         function hideError() {
  282.             errorText.style.display = 'none';
  283.         }
  284.         // 6. 绑定按钮事件(核心修复:原程序缺少这一步)
  285.         findBtn.addEventListener('click', addVideos);
  286.         clearBtn.addEventListener('click', clearVideoList);
  287.         // 7. 支持回车键触发查找(提升操作体验)
  288.         videoInput.addEventListener('keydown', (e) => {
  289.             if (e.key === 'Enter') {
  290.                 addVideos();
  291.             }
  292.         });
  293.         // 说明:原程序的“禁止右键/F12”逻辑已移除,原因如下:
  294.         // 1. 无法真正阻止专业用户查看源码(浏览器调试模式可绕过)
  295.         // 2. 影响正常用户操作(如右键复制文本、刷新页面)
  296.         // 3. 若需保护视频,应通过后端权限控制(如签名URL、时效验证),而非前端隐藏
  297.     </script>
  298. </body>
  299. </html>
复制代码

帮你修改正了下,就可以了
回复

使用道具 举报

发表于 前天 05:47 | 显示全部楼层
有创意的
回复

使用道具 举报

发表于 前天 05:47 | 显示全部楼层
这个可以试一下。
回复

使用道具 举报

发表于 前天 05:48 | 显示全部楼层
这个是干嘛的
回复

使用道具 举报

发表于 前天 05:48 | 显示全部楼层
用于本地播放自己的视频使用的。
回复

使用道具 举报

发表于 前天 05:49 | 显示全部楼层
高端大气上档次,就是目前不太需要,支持了~
回复

使用道具 举报

发表于 前天 05:50 | 显示全部楼层
试试好用不,谢谢
回复

使用道具 举报

发表于 前天 05:50 | 显示全部楼层
方便实用,感谢分享。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表