v-fixed17:/live 默认播放 TVB 翡翠台(静音自动播+点击开声)
This commit is contained in:
1 parent
d885670cfe
commit
05aa1cef64
4 files changed
+24
-9
No files matched your search
@@ -2,6 +2,12 @@
|
||||
|
||||
格式参考本机发版惯例:按日期分条,`🐛修复` / `✨新功能`。
|
||||
|
||||
## 2026-10-26 → v-fixed17
|
||||
|
||||
- ✨ **打开直播默认播放 TVB 翡翠台**:频道列表加载完自动选中 id=5(找不到则按名字含「翡翠」匹配,再兜底第一个频道)并起播
|
||||
- ✨ **静音自动播放**:默认静音自动播(浏览器自动播放策略全绿,画面即开即动);播放后提示「🔇 静音自动播放 · 点击画面开启声音」4 秒;点击画面任意处或中央 ▶ 按钮即开启声音
|
||||
- 🔧 自动选台不触发移动端滚动(仅用户手动点频道才滚到播放器)
|
||||
|
||||
## 2026-10-26 → v-fixed16
|
||||
|
||||
- 🐛 **修复 `/live` 打开是代码(JSON)**:Next 的 rewrite 到 API 路由时保留原 URL `/live`、静态 query 全丢,导致直播钩子不触发而返回 TVBOX config JSON;改为按 `pathname === "/live"` 识别(实测登录态返回 `text/html`)
|
||||
|
||||
@@ -3,7 +3,7 @@ version: '3.8'
|
||||
services:
|
||||
# KatelyaTV 应用服务
|
||||
katelyatv:
|
||||
image: katelyatv:fixed16
|
||||
image: katelyatv:fixed17
|
||||
container_name: katelyatv
|
||||
ports:
|
||||
- "3030:3000"
|
||||
|
||||
+16
-8
@@ -69,6 +69,7 @@ body{background:#0f1115;color:#e5e7eb;font-family:-apple-system,BlinkMacSystemFo
|
||||
.player-box{background:#000;border-radius:10px;overflow:hidden;aspect-ratio:16/9;position:relative}
|
||||
video{width:100%;height:100%;display:block;background:#000}
|
||||
.tip{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#6b7280;font-size:14px;pointer-events:none;background:rgba(0,0,0,.35)}
|
||||
.bigplay{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(0,0,0,.45);color:#fff;font-size:64px;cursor:pointer;z-index:5;user-select:none}
|
||||
.bar{display:flex;align-items:center;gap:10px;font-size:13px;color:#9ca3af}
|
||||
.bar .cur{color:#fff;font-weight:600;font-size:15px}
|
||||
select{background:#171b24;color:#e5e7eb;border:1px solid #2a3140;border-radius:6px;padding:5px 8px;font-size:13px}
|
||||
@@ -83,7 +84,7 @@ select{background:#171b24;color:#e5e7eb;border:1px solid #2a3140;border-radius:6
|
||||
<div class="wrap">
|
||||
<div class="side"><div class="sec">频道列表 <span style="color:#4b5563">点击切换</span></div><div class="grid" id="grid"><div class="empty">加载中…</div></div></div>
|
||||
<div class="main">
|
||||
<div class="player-box"><video id="v" playsinline></video><div class="tip" id="tip">选择频道开始观看</div></div>
|
||||
<div class="player-box"><video id="v" playsinline></video><div class="tip" id="tip">选择频道开始观看</div><div class="bigplay" id="bigplay">▶</div></div>
|
||||
<div class="bar" style="margin-top:10px"><span class="cur" id="cur">未选择</span><span style="flex:1"></span>
|
||||
<label>线路 <select id="lineSel" onchange="playLine(this.value)"></select></label></div>
|
||||
</div>
|
||||
@@ -92,22 +93,27 @@ select{background:#171b24;color:#e5e7eb;border:1px solid #2a3140;border-radius:6
|
||||
var hls=null,mp=null,chs=[],curId=null;
|
||||
var v=document.getElementById('v'),tip=document.getElementById('tip'),
|
||||
grid=document.getElementById('grid'),sel=document.getElementById('lineSel'),
|
||||
cur=document.getElementById('cur');
|
||||
cur=document.getElementById('cur'),bigplay=document.getElementById('bigplay');
|
||||
var API='/api/tvbox?live=';
|
||||
function stopAll(){if(hls){hls.destroy();hls=null}if(mp){mp.destroy();mp=null}try{v.removeAttribute('src');v.load()}catch(e){}}
|
||||
function playSrc(u,flv){
|
||||
stopAll();
|
||||
if(flv&&window.mpegts){try{mp=mpegts.createPlayer({type:'flv',isLive:true,url:u,liveBufferLatencyChasing:true});mp.attachMediaElement(v);mp.load()}catch(e){}}
|
||||
else if(/\\.m3u8/.test(u)){
|
||||
if(v.canPlayType('application/vnd.apple.mpegurl')){v.src=u}
|
||||
else if(/\\.m3u8/.test(u)){ if(v.canPlayType('application/vnd.apple.mpegurl')){v.src=u}
|
||||
else if(window.Hls&&Hls.isSupported()){hls=new Hls({maxBufferLength:10,manifestLoadingMaxRetry:2,levelLoadingMaxRetry:2,fragLoadingMaxRetry:3});
|
||||
hls.loadSource(u);hls.attachMedia(v);
|
||||
hls.on(Hls.Events.ERROR,function(e,d){if(d.fatal){if(d.type===Hls.ErrorTypes.NETWORK_ERROR){hls.startLoad()}else if(d.type===Hls.ErrorTypes.MEDIA_ERROR){hls.recoverMediaError()}else{nextLine()}}})}
|
||||
}else if(/\\.flv/.test(u)&&window.mpegts){try{mp=mpegts.createPlayer({type:'flv',isLive:true,url:u});mp.attachMediaElement(v);mp.load()}catch(e){}}
|
||||
v.play().catch(function(){});
|
||||
v.muted=true;
|
||||
var pr=v.play();
|
||||
if(pr&&pr.catch)pr.catch(function(){bigplay.style.display='flex'});
|
||||
setTimeout(function(){if(v.readyState<2&&v.paused)tip.style.display='flex'},2500);
|
||||
v.onplaying=function(){tip.style.display='none'};
|
||||
v.onplaying=function(){tip.style.display='none';
|
||||
if(v.muted){tip.textContent='🔇 静音自动播放 · 点击画面开启声音';tip.style.display='flex';
|
||||
setTimeout(function(){tip.style.display='none'},4000)}};
|
||||
}
|
||||
bigplay.addEventListener('click',function(){v.muted=false;bigplay.style.display='none';v.play().catch(function(){})});
|
||||
v.addEventListener('click',function(){if(v.muted){v.muted=false;bigplay.style.display='none'}});
|
||||
function nextLine(){if(sel.options.length&&+sel.value<sel.options.length-1){sel.value=+sel.value+1;playLine(sel.value)}else{tip.textContent='所有线路暂不可用';tip.style.display='flex'}}
|
||||
window.nextLine=nextLine;
|
||||
function playLine(p){
|
||||
@@ -119,12 +125,12 @@ function playLine(p){
|
||||
}).catch(function(){nextLine()});
|
||||
}
|
||||
window.playLine=playLine;
|
||||
function pick(id){
|
||||
function pick(id,auto){
|
||||
curId=id;
|
||||
document.querySelectorAll('.ch.on').forEach(function(e){e.classList.remove('on')});
|
||||
var el=document.querySelector('.ch[data-id="'+id+'"]');if(el)el.classList.add('on');
|
||||
sel.innerHTML='';tip.textContent='加载线路…';tip.style.display='flex';
|
||||
if(window.innerWidth<820){var pb=document.querySelector('.player-box');if(pb)pb.scrollIntoView({behavior:'smooth',block:'center'})}
|
||||
if(!auto&&window.innerWidth<820){var pb=document.querySelector('.player-box');if(pb)pb.scrollIntoView({behavior:'smooth',block:'center'})}
|
||||
fetch(API+'lines&id='+id).then(function(r){return r.json()}).then(function(j){
|
||||
(j.lines||[]).forEach(function(l,i){var o=document.createElement('option');o.value=i;o.textContent=l.name;sel.appendChild(o)});
|
||||
if((j.lines||[]).length){sel.value=0;playLine(0)}else{tip.textContent='暂无可用线路'}
|
||||
@@ -136,6 +142,8 @@ fetch(API+'channels').then(function(r){return r.json()}).then(function(j){
|
||||
grid.innerHTML='';
|
||||
chs.forEach(function(c){var d=document.createElement('div');d.className='ch';d.dataset.id=c.id;d.textContent=c.name;
|
||||
d.onclick=function(){pick(c.id)};grid.appendChild(d)});
|
||||
var DEF=chs.find(function(c){return c.id==='5'})||chs.find(function(c){return (c.name||'').indexOf('翡翠')>=0})||chs[0];
|
||||
if(DEF){pick(DEF.id,1)}
|
||||
}).catch(function(){grid.innerHTML='<div class="empty">加载失败,请刷新</div>'});
|
||||
</script></body></html>`;
|
||||
return new Response(html,{headers:{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}})}
|
||||
|
||||
Reference in new issue
Block a user