风萧 发表于 4 天前

[十八岁太奶奶驾到,重整家族荣耀][第三季全集]

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Discuz M3U8 分集播放器</title>
    <!-- 引入 TailwindCSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
      tailwind.config = {
      corePlugins: {
      preflight: false, // 关闭Tailwind的全局重置样式,避免覆盖Discuz原有页面样式
                     }
      }
    </script>
    <!-- 引入 Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <!-- 引入 Hls.js -->
    <script src="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js"></script>
    <style>
      /* 自定义滚动条样式 */
      .episode-scroll::-webkit-scrollbar {
            width: 6px;
            height: 6px;
      }
      .episode-scroll::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 3px;
      }
      .episode-scroll::-webkit-scrollbar-thumb {
            background: #cbd5e1;
            border-radius: 3px;
      }
      .episode-scroll::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
      }
      /* 选中状态动画 */
      .episode-btn.active {
            background-color: #3b82f6;
            color: white;
            border-color: #3b82f6;
      }
      /* 加载动画 */
      .loader {
            border: 3px solid #f3f3f3;
            border-radius: 50%;
            border-top: 3px solid #3b82f6;
            width: 24px;
            height: 24px;
            -webkit-animation: spin 1s linear infinite; /* Safari */
            animation: spin 1s linear infinite;
      }
      @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
      }
    </style>
</head>
<body class="bg-gray-100 p-4 font-sans">

    <!-- 播放器容器 -->
    <div id="dz-video-player-container" class="max-w-4xl mx-auto bg-white rounded-xl shadow-lg overflow-hidden border border-gray-200" style="isolation: isolate;">
      
      <!-- 视频区域 -->
      <div class="relative w-full aspect-video bg-black group">
            <video id="dz-video-element" class="w-full h-full object-contain" controls playsinline poster="/data/attachment/album/202608/31/200711vfnhzq7opn8dqp00.jpg"></video>
            
            <!-- 加载指示器 -->
            <div id="dz-loading-indicator" class="absolute inset-0 flex items-center justify-center bg-black/50 hidden z-10">
                <div class="loader"></div>
            </div>

            <!-- 错误提示层 -->
            <div id="dz-error-overlay" class="absolute inset-0 flex flex-col items-center justify-center bg-black/80 text-white hidden z-20">
                <i class="fas fa-exclamation-triangle text-4xl mb-2 text-red-500"></i>
                <p class="text-sm">视频加载失败,请检查网络或链接有效性</p>
                <button onclick="retryLoad()" class="mt-4 px-4 py-2 bg-blue-600 hover:bg-blue-700 rounded text-sm transition">重试</button>
            </div>
      </div>

      <!-- 控制面板:标题与分集 -->
      <div class="p-4 bg-white">
            <div class="flex justify-between items-center mb-4 border-b pb-2">
                <h2 id="dz-video-title" class="text-lg font-bold text-gray-800 truncate pr-4">正在播放:第 1 集</h2>
                <!-- div class="text-xs text-gray-500 flex items-center gap-2">
                  <span id="dz-quality-badge" class="px-2 py-1 bg-gray-100 rounded text-gray-600">HD</span>
                  <span id="dz-duration">00:00</span>
                </div -->
            </div>

            <!-- 分集列表 -->
            <div class="mb-2 flex justify-between items-center">
                <span class="text-sm font-semibold text-gray-700"><i class="fas fa-list-ul mr-1"></i> 选集</span>
                <div class="flex gap-2">
                     <button onclick="toggleOrder()" class="text-xs text-blue-600 hover:text-blue-800 flex items-center gap-1">
                        <i class="fas fa-sort-amount-down" id="sort-icon"></i> <span id="sort-text">倒序</span>
                  </button>
                </div>
            </div>
            
            <div id="dz-episode-list" class="grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-2 max-h-40 overflow-y-auto episode-scroll p-1">
                <!-- 分集按钮将通过 JS 动态生成 -->
            </div>
      </div>
    </div>

    <script>
      /**
         * Discuz M3U8 Player Configuration
         * 在 Discuz 发帖时,只需修改此处的 videoData 数组即可
         */
      const videoData = [
            { title: "第01集", url: "https://v.lzfile26.com/20251027/222854_94e24757/2000k/hls/mixed.m3u8"},
            { title: "第02集", url: "https://v.lzfile26.com/20251027/222856_0f01d80f/2000k/hls/mixed.m3u8"},
            { title: "第03集", url: "https://v.lzfile26.com/20251027/222855_a48067a1/2000k/hls/mixed.m3u8"},
            { title: "第04集", url: "https://v.lzfile26.com/20251027/222859_e4786f1f/2000k/hls/mixed.m3u8"},
            { title: "第05集", url: "https://v.lzfile26.com/20251027/222858_dca152c4/2000k/hls/mixed.m3u8"},
            { title: "第06集", url: "https://v.lzfile26.com/20251027/222857_1d46d84e/2000k/hls/mixed.m3u8"},
            { title: "第07集", url: "https://v.lzfile26.com/20251027/222862_b7cce44e/2000k/hls/mixed.m3u8"},
            { title: "第08集", url: "https://v.lzfile26.com/20251027/222860_fa67c795/2000k/hls/mixed.m3u8"},
            { title: "第09集", url: "https://v.lzfile26.com/20251027/222861_3cdd0c4a/2000k/hls/mixed.m3u8"},
            { title: "第10集", url: "https://v.lzfile26.com/20251027/222864_c14e415c/2000k/hls/mixed.m3u8"},
            { title: "第11集", url: "https://v.lzfile26.com/20251027/222863_eabbdda6/2000k/hls/mixed.m3u8"},
            { title: "第12集", url: "https://v.lzfile26.com/20251027/222865_5e204551/2000k/hls/mixed.m3u8"},
            { title: "第13集", url: "https://v.lzfile26.com/20251027/222866_a51f9fd9/2000k/hls/mixed.m3u8"},
            { title: "第14集", url: "https://v.lzfile26.com/20251027/222868_56301a3b/2000k/hls/mixed.m3u8"},
            { title: "第15集", url: "https://v.lzfile26.com/20251027/222867_ae18002c/2000k/hls/mixed.m3u8"},
            { title: "第16集", url: "https://v.lzfile26.com/20251027/222869_2cf4aadb/2000k/hls/mixed.m3u8"},
            { title: "第17集", url: "https://v.lzfile26.com/20251027/222870_5792bb29/2000k/hls/mixed.m3u8"},
            { title: "第18集", url: "https://v.lzfile26.com/20251027/222871_31a526c8/2000k/hls/mixed.m3u8"},
            { title: "第19集", url: "https://v.lzfile26.com/20251027/222872_a53f1313/2000k/hls/mixed.m3u8"},
            { title: "第20集", url: "https://v.lzfile26.com/20251027/222873_ada54cf8/2000k/hls/mixed.m3u8"},
            { title: "第21集", url: "https://v.lzfile26.com/20251027/222874_84af5434/2000k/hls/mixed.m3u8"},
            { title: "第22集", url: "https://v.lzfile26.com/20251027/222875_1c520117/2000k/hls/mixed.m3u8"},
            { title: "第23集", url: "https://v.lzfile26.com/20251027/222876_f724055d/2000k/hls/mixed.m3u8"},
            { title: "第24集", url: "https://v.lzfile26.com/20251027/222877_1677e1fc/2000k/hls/mixed.m3u8"},
            { title: "第25集", url: "https://v.lzfile26.com/20251027/222879_0db6f380/2000k/hls/mixed.m3u8"},
            { title: "第26集", url: "https://v.lzfile26.com/20251027/222878_da54fd61/2000k/hls/mixed.m3u8"},
            { title: "第27集", url: "https://v.lzfile26.com/20251027/222880_257ae8d3/2000k/hls/mixed.m3u8"},
            { title: "第28集", url: "https://v.lzfile26.com/20251027/222882_c9ef63e8/2000k/hls/mixed.m3u8"},
            { title: "第29集", url: "https://v.lzfile26.com/20251027/222881_dc2db7ff/2000k/hls/mixed.m3u8"},
            { title: "第30集", url: "https://v.lzfile26.com/20251027/222883_905b4b56/2000k/hls/mixed.m3u8"},
            { title: "第31集", url: "https://v.lzfile26.com/20251027/222884_9edebcab/2000k/hls/mixed.m3u8"},
            { title: "第32集", url: "https://v.lzfile26.com/20251027/222885_c10d94f6/2000k/hls/mixed.m3u8"},
            { title: "第33集", url: "https://v.lzfile26.com/20251027/222886_b8860536/2000k/hls/mixed.m3u8"},
            { title: "第34集", url: "https://v.lzfile26.com/20251027/222887_a46d2dfe/2000k/hls/mixed.m3u8"},
            { title: "第35集", url: "https://v.lzfile26.com/20251027/222888_56b74671/2000k/hls/mixed.m3u8"},
            { title: "第36集", url: "https://v.lzfile26.com/20251027/222889_d7108aa9/2000k/hls/mixed.m3u8"},
            { title: "第37集", url: "https://v.lzfile26.com/20251027/222890_e4d28a87/2000k/hls/mixed.m3u8"},
            { title: "第38集", url: "https://v.lzfile26.com/20251027/222891_8e9d03e5/2000k/hls/mixed.m3u8"},
            { title: "第39集", url: "https://v.lzfile26.com/20251027/222892_35ddc1cd/2000k/hls/mixed.m3u8"},
            { title: "第40集", url: "https://v.lzfile26.com/20251027/222894_2ff04425/2000k/hls/mixed.m3u8"},
            { title: "第41集", url: "https://v.lzfile26.com/20251027/222893_275a9785/2000k/hls/mixed.m3u8"},
            { title: "第42集", url: "https://v.lzfile26.com/20251027/222895_4e391568/2000k/hls/mixed.m3u8"},
            { title: "第43集", url: "https://v.lzfile26.com/20251027/222896_90753ee5/2000k/hls/mixed.m3u8"},
            { title: "第44集", url: "https://v.lzfile26.com/20251027/222897_a7b13ad4/2000k/hls/mixed.m3u8"},
            { title: "第45集", url: "https://v.lzfile26.com/20251027/222900_02a6e682/2000k/hls/mixed.m3u8"},
            { title: "第46集", url: "https://v.lzfile26.com/20251027/222898_22e1489b/2000k/hls/mixed.m3u8"},
            { title: "第47集", url: "https://v.lzfile26.com/20251027/222899_e960cac3/2000k/hls/mixed.m3u8"},
            { title: "第48集", url: "https://v.lzfile26.com/20251027/222901_d2400589/2000k/hls/mixed.m3u8"},
          { title: "第49集", url: "https://v.lzfile26.com/20251027/222902_3527eeca/2000k/hls/mixed.m3u8"},
          { title: "第50集", url: "https://v.lzfile26.com/20251027/222903_9edf9358/2000k/hls/mixed.m3u8"},
          { title: "第51集", url: "https://v.lzfile26.com/20251027/222905_4cd738d5/2000k/hls/mixed.m3u8"},
          { title: "第52集", url: "https://v.lzfile26.com/20251027/222904_ce1822ff/2000k/hls/mixed.m3u8"},
          { title: "第53集", url: "https://v.lzfile26.com/20251027/222906_d9b9dcec/2000k/hls/mixed.m3u8"},
          { title: "第54集", url: "https://v.lzfile26.com/20251027/222908_318be86a/2000k/hls/mixed.m3u8"},
          { title: "第55集", url: "https://v.lzfile26.com/20251027/222907_5ce34554/2000k/hls/mixed.m3u8"},
          { title: "第56集", url: "https://v.lzfile26.com/20251027/222909_5b452e8d/2000k/hls/mixed.m3u8"},
          { title: "第57集", url: "https://v.lzfile26.com/20251027/222910_6fc72e4a/2000k/hls/mixed.m3u8"},
          { title: "第58集", url: "https://v.lzfile26.com/20251027/222911_6af92071/2000k/hls/mixed.m3u8"},
          { title: "第59集", url: "https://v.lzfile26.com/20251027/222912_4570f073/2000k/hls/mixed.m3u8"},
          { title: "第60集", url: "https://v.lzfile26.com/20251027/222914_0de1cda0/2000k/hls/mixed.m3u8"},
          { title: "第61集", url: "https://v.lzfile26.com/20251027/222913_2396bb31/2000k/hls/mixed.m3u8"},
          { title: "第62集", url: "https://v.lzfile26.com/20251027/222915_3a8e857a/2000k/hls/mixed.m3u8"},
          { title: "第63集", url: "https://v.lzfile26.com/20251027/222917_63fd4390/2000k/hls/mixed.m3u8"},
          { title: "第64集", url: "https://v.lzfile26.com/20251027/222918_334aff43/2000k/hls/mixed.m3u8"},
          { title: "第65集", url: "https://v.lzfile26.com/20251027/222916_e18f4f02/2000k/hls/mixed.m3u8"},
          { title: "第66集", url: "https://v.lzfile26.com/20251027/222919_16e1b300/2000k/hls/mixed.m3u8"},
          { title: "第67集", url: "https://v.lzfile26.com/20251027/222920_58fc5369/2000k/hls/mixed.m3u8"},
          { title: "第68集", url: "https://v.lzfile26.com/20251027/222921_17176b0a/2000k/hls/mixed.m3u8"},
          { title: "第69集", url: "https://v.lzfile26.com/20251027/222924_8a3b60f6/2000k/hls/mixed.m3u8"},
          { title: "第70集", url: "https://v.lzfile26.com/20251027/222923_bb7490cb/2000k/hls/mixed.m3u8"},
          { title: "第71集", url: "https://v.lzfile26.com/20251027/222922_2566b776/2000k/hls/mixed.m3u8"},
          { title: "第72集", url: "https://v.lzfile26.com/20251027/222926_9a02c4b6/2000k/hls/mixed.m3u8"},
          { title: "第73集", url: "https://v.lzfile26.com/20251027/222925_c234b47a/2000k/hls/mixed.m3u8"},
          { title: "第74集", url: "https://v.lzfile26.com/20251027/222927_83ddd97a/2000k/hls/mixed.m3u8"},
          { title: "第75集", url: "https://v.lzfile26.com/20251027/222928_8a602131/2000k/hls/mixed.m3u8"},
          { title: "第76集", url: "https://v.lzfile26.com/20251027/222929_c39ee278/2000k/hls/mixed.m3u8"},
          { title: "第77集", url: "https://v.lzfile26.com/20251027/222930_2c2379b2/2000k/hls/mixed.m3u8"},
          { title: "第78集", url: "https://v.lzfile26.com/20251027/222931_bc935bae/2000k/hls/mixed.m3u8"},
          { title: "第79集", url: "https://v.lzfile26.com/20251027/222932_ac717ad4/2000k/hls/mixed.m3u8"},
          { title: "第80集", url: "https://v.lzfile26.com/20251027/222933_8ab5113e/2000k/hls/mixed.m3u8"},
          { title: "第81集", url: "https://v.lzfile26.com/20251027/222934_c4a66f3d/2000k/hls/mixed.m3u8"},
          { title: "第82集", url: "https://v.lzfile26.com/20251027/222935_d564d6e2/2000k/hls/mixed.m3u8"},
          { title: "第83集", url: "https://v.lzfile26.com/20251027/222936_8668c628/2000k/hls/mixed.m3u8"},
          { title: "第84集", url: "https://v.lzfile26.com/20251027/222937_fe565c10/2000k/hls/mixed.m3u8"}
      ];

      // 全局变量
      let hls = null;
      let currentEpisodeIndex = 0;
      let isReversed = false;
      let displayedData = [...videoData];
      const videoElement = document.getElementById('dz-video-element');
      const episodeListContainer = document.getElementById('dz-episode-list');
      const loadingIndicator = document.getElementById('dz-loading-indicator');
      const errorOverlay = document.getElementById('dz-error-overlay');
      const titleElement = document.getElementById('dz-video-title');
      const durationElement = document.getElementById('dz-duration');

      /**
         * 初始化播放器
         */
      function initPlayer() {
            renderEpisodes();
            loadEpisode(0); // 默认加载第一集
            
            // 监听视频元数据加载完成,更新时长显示
            videoElement.addEventListener('loadedmetadata', () => {
                durationElement.innerText = formatTime(videoElement.duration);
            });

            // 监听播放结束,自动下一集
            videoElement.addEventListener('ended', () => {
                playNext();
            });
      }

      /**
         * 渲染分集列表
         */
      function renderEpisodes() {
            episodeListContainer.innerHTML = '';
            displayedData.forEach((item, index) => {
                // 找到原始数据中的真实索引,用于点击事件
                const originalIndex = videoData.indexOf(item);
               
                const btn = document.createElement('button');
                btn.className = `episode-btn px-3 py-2 text-xs font-medium rounded border border-gray-200 text-gray-700 hover:bg-blue-50 hover:border-blue-200 transition-all truncate ${originalIndex === currentEpisodeIndex ? 'active' : ''}`;
                btn.innerText = item.title;
                btn.onclick = () => loadEpisode(originalIndex);
                episodeListContainer.appendChild(btn);
            });
      }

      /**
         * 加载指定集数
         * @param {number} index - 原始数据数组中的索引
         */
      function loadEpisode(index) {
            if (index < 0 || index >= videoData.length) return;

            currentEpisodeIndex = index;
            const data = videoData;
            
            // 更新UI状态
            updateActiveButton();
            titleElement.innerText = `正在播放:${data.title}`;
            showLoading(true);
            hideError();

            // 销毁旧的 HLS 实例
            if (hls) {
                hls.destroy();
            }

            // 创建新的 HLS 实例
            if (Hls.isSupported()) {
                hls = new Hls({
                  debug: false,
                  enableWorker: true,
                  lowLatencyMode: true,
                  backBufferLength: 90
                });

                hls.loadSource(data.url);
                hls.attachMedia(videoElement);

                hls.on(Hls.Events.MANIFEST_PARSED, function() {
                  videoElement.play().catch(e => console.log("Auto-play prevented:", e));
                  showLoading(false);
                });

                hls.on(Hls.Events.ERROR, function(event, data) {
                  if (data.fatal) {
                        switch(data.type) {
                            case Hls.ErrorTypes.NETWORK_ERROR:
                              console.log("fatal network error encountered, try to recover");
                              hls.startLoad();
                              break;
                            case Hls.ErrorTypes.MEDIA_ERROR:
                              console.log("fatal media error encountered, try to recover");
                              hls.recoverMediaError();
                              break;
                            default:
                              showError();
                              hls.destroy();
                              break;
                        }
                  }
                });

            } else if (videoElement.canPlayType('application/vnd.apple.mpegurl')) {
                // Safari 原生支持
                videoElement.src = data.url;
                videoElement.addEventListener('loadedmetadata', function() {
                  videoElement.play();
                  showLoading(false);
                });
            } else {
                showError();
            }
      }

      /**
         * 更新按钮激活状态
         */
      function updateActiveButton() {
            const buttons = episodeListContainer.querySelectorAll('.episode-btn');
            buttons.forEach((btn, idx) => {
                // 注意:displayedData 可能是反转的,所以需要比对内容或重新映射
                // 这里简单起见,我们重新渲染或者通过文本匹配,但更优解是重新渲染
                // 为了性能,我们直接重新渲染整个列表是最安全的,因为列表通常不长
                renderEpisodes();
            });
      }

      /**
         * 播放下一集
         */
      function playNext() {
            if (currentEpisodeIndex < videoData.length - 1) {
                loadEpisode(currentEpisodeIndex + 1);
                // 滚动到当前选中的按钮
                setTimeout(() => {
                  const activeBtn = document.querySelector('.episode-btn.active');
                  if(activeBtn) activeBtn.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
                }, 100);
            }
      }

      /**
         * 切换排序(正序/倒序)
         */
      function toggleOrder() {
            isReversed = !isReversed;
            const sortIcon = document.getElementById('sort-icon');
            const sortText = document.getElementById('sort-text');
            
            if (isReversed) {
                displayedData = [...videoData].reverse();
                sortIcon.className = "fas fa-sort-amount-up";
                sortText.innerText = "正序";
            } else {
                displayedData = [...videoData];
                sortIcon.className = "fas fa-sort-amount-down";
                sortText.innerText = "倒序";
            }
            renderEpisodes();
      }

      /**
         * 重试加载
         */
      function retryLoad() {
            loadEpisode(currentEpisodeIndex);
      }

      /**
         * UI 辅助函数
         */
      function showLoading(show) {
            loadingIndicator.classList.toggle('hidden', !show);
      }

      function showError() {
            errorOverlay.classList.remove('hidden');
            showLoading(false);
      }

      function hideError() {
            errorOverlay.classList.add('hidden');
      }

      function formatTime(seconds) {
            if (isNaN(seconds)) return "00:00";
            const m = Math.floor(seconds / 60);
            const s = Math.floor(seconds % 60);
            return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
      }

      // 启动
      document.addEventListener('DOMContentLoaded', initPlayer);

    </script>
</body>
</html>
页: [1]
查看完整版本: [十八岁太奶奶驾到,重整家族荣耀][第三季全集]