v-fixed21:切台显示实时加载计时,画面播放成功才消失
This commit is contained in:
1 parent
66c77ca267
commit
e88cd47969
3 files changed
+14
-6
No files matched your search
@@ -2,6 +2,10 @@
|
||||
|
||||
格式参考本机发版惯例:按日期分条,`🐛修复` / `✨新功能`。
|
||||
|
||||
## 2026-10-26 → v-fixed21
|
||||
|
||||
- ✨ **切台加载计时**:点击频道后播放器显示「加载中… X.Xs」实时计时(0.1s 精度),线路切换/自动重试期间计时不中断,画面真正播放(playing 事件)才停止并隐藏;解析失败(无线路/全部线路不可用)时计时停止并显示原因
|
||||
|
||||
## 2026-10-26 → v-fixed20
|
||||
|
||||
- ✨ **默认播放改为有声优先**:打开 /live 直接尝试带声播放 TVB 翡翠台;仅当浏览器自动播放策略拦截时才回退静音(画面先动,点画面/点频道立即开声)
|
||||
|
||||
@@ -3,7 +3,7 @@ version: '3.8'
|
||||
services:
|
||||
# KatelyaTV 应用服务
|
||||
katelyatv:
|
||||
image: katelyatv:fixed20
|
||||
image: katelyatv:fixed21
|
||||
container_name: katelyatv
|
||||
ports:
|
||||
- "3030:3000"
|
||||
|
||||
@@ -104,6 +104,11 @@ var v=document.getElementById('v'),tip=document.getElementById('tip'),
|
||||
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){}}
|
||||
var loadTimer=null;
|
||||
function startTick(){if(loadTimer)clearInterval(loadTimer);var t0=Date.now();
|
||||
tip.style.display='flex';tip.textContent='加载中… 0.0s';
|
||||
loadTimer=setInterval(function(){tip.textContent='加载中… '+((Date.now()-t0)/1000).toFixed(1)+'s'},100)}
|
||||
function stopTick(){if(loadTimer){clearInterval(loadTimer);loadTimer=null}}
|
||||
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){}}
|
||||
@@ -115,17 +120,16 @@ function playSrc(u,flv){
|
||||
var pr=v.play();
|
||||
if(pr&&pr.catch)pr.catch(function(){v.muted=true;var pr2=v.play();if(pr2&&pr2.catch)pr2.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(){stopTick();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'}}
|
||||
function nextLine(){if(sel.options.length&&+sel.value<sel.options.length-1){sel.value=+sel.value+1;playLine(sel.value)}else{stopTick();tip.textContent='所有线路暂不可用';tip.style.display='flex'}}
|
||||
window.nextLine=nextLine;
|
||||
function playLine(p){
|
||||
if(!curId)return;
|
||||
tip.textContent='加载中…';tip.style.display='flex';
|
||||
fetch(API+'m3u8&id='+curId+'&p='+p).then(function(r){return r.json()}).then(function(j){
|
||||
if(j.url){cur.textContent=(chs.find(function(c){return c.id==curId})||{}).name||'';playSrc(j.url,!!j.flv)}
|
||||
else{nextLine()}
|
||||
@@ -137,11 +141,11 @@ function pick(id,auto){
|
||||
if(!auto){v.muted=false;bigplay.style.display='none'}
|
||||
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';
|
||||
sel.innerHTML='';startTick();
|
||||
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='暂无可用线路'}
|
||||
if((j.lines||[]).length){sel.value=0;playLine(0)}else{stopTick();tip.textContent='暂无可用线路'}
|
||||
}).catch(function(){tip.textContent='线路解析失败'});
|
||||
}
|
||||
fetch(API+'channels').then(function(r){return r.json()}).then(function(j){
|
||||
|
||||
Reference in new issue
Block a user