seawolf2357 commited on
Commit
fb2f1e6
·
verified ·
1 Parent(s): 38a3bbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -395,6 +395,7 @@ function addMedia(name,type,url,filePath){{
395
  var m={{id:id(),name:name,type:type,url:url,filePath:filePath||name,dur:type==='image'?5:0,thumb:type==='image'?url:null}};
396
  S.media.push(m);
397
  var container=document.getElementById('hiddenMedia');
 
398
  if(type==='video'){{
399
  var v=document.createElement('video');
400
  v.src=url;
@@ -402,8 +403,13 @@ v.muted=false;
402
  v.playsInline=true;
403
  v.preload='auto';
404
  v.crossOrigin='anonymous';
 
 
405
  container.appendChild(v);
406
  S.els[m.id]=v;
 
 
 
407
  v.onloadedmetadata=function(){{
408
  m.dur=r(v.duration);
409
  renderLib();
@@ -703,11 +709,18 @@ if(S.playing)play();else stop();
703
 
704
  function play(){{
705
  var last=performance.now();
 
 
706
  function loop(now){{
707
  if(!S.playing)return;
708
- var dt=(now-last)/1000;
709
- last=now;
710
- S.time=S.time+dt;
 
 
 
 
 
711
  if(S.time>=S.dur){{
712
  S.time=0;
713
  if(S.dur===0){{S.playing=false;document.getElementById('playBtn').textContent='▶';return}}
@@ -764,11 +777,14 @@ S.ctx.fillRect(0,0,pw,ph);
764
  if(vc){{
765
  var el=S.els[vc.mid];
766
  if(el){{
 
767
  if(vc.type==='video'){{
768
  var clipT=t-vc.start+vc.ts;
769
- if(Math.abs(el.currentTime-clipT)>0.05){{
770
  el.currentTime=clipT;
771
  }}
 
 
772
  if(S.playing&&el.paused)el.play().catch(function(){{}});
773
  if(!S.playing&&!el.paused)el.pause();
774
  el.volume=S.muted?0:vc.vol;
@@ -794,7 +810,7 @@ audioClips.forEach(function(ac){{
794
  var el=S.els[ac.mid];
795
  if(el){{
796
  var clipT=t-ac.start+ac.ts;
797
- if(Math.abs(el.currentTime-clipT)>0.1)el.currentTime=clipT;
798
  el.volume=S.muted?0:ac.vol;
799
  if(S.playing&&el.paused)el.play().catch(function(){{}});
800
  if(!S.playing&&!el.paused)el.pause();
 
395
  var m={{id:id(),name:name,type:type,url:url,filePath:filePath||name,dur:type==='image'?5:0,thumb:type==='image'?url:null}};
396
  S.media.push(m);
397
  var container=document.getElementById('hiddenMedia');
398
+
399
  if(type==='video'){{
400
  var v=document.createElement('video');
401
  v.src=url;
 
403
  v.playsInline=true;
404
  v.preload='auto';
405
  v.crossOrigin='anonymous';
406
+ v.setAttribute('playsinline','');
407
+ v.setAttribute('webkit-playsinline','');
408
  container.appendChild(v);
409
  S.els[m.id]=v;
410
+ // 버퍼링 강화: 전체 로드 대기
411
+ v.load();
412
+
413
  v.onloadedmetadata=function(){{
414
  m.dur=r(v.duration);
415
  renderLib();
 
709
 
710
  function play(){{
711
  var last=performance.now();
712
+ var targetFPS=30;
713
+ var frameInterval=1000/targetFPS;
714
  function loop(now){{
715
  if(!S.playing)return;
716
+ var dt=(now-last);
717
+ if(dt<frameInterval){{
718
+ S.animId=requestAnimationFrame(loop);
719
+ return;
720
+ }}
721
+ last=now-(dt%frameInterval);
722
+ S.time=S.time+dt/1000;
723
+
724
  if(S.time>=S.dur){{
725
  S.time=0;
726
  if(S.dur===0){{S.playing=false;document.getElementById('playBtn').textContent='▶';return}}
 
777
  if(vc){{
778
  var el=S.els[vc.mid];
779
  if(el){{
780
+
781
  if(vc.type==='video'){{
782
  var clipT=t-vc.start+vc.ts;
783
+ if(Math.abs(el.currentTime-clipT)>0.3){{
784
  el.currentTime=clipT;
785
  }}
786
+
787
+
788
  if(S.playing&&el.paused)el.play().catch(function(){{}});
789
  if(!S.playing&&!el.paused)el.pause();
790
  el.volume=S.muted?0:vc.vol;
 
810
  var el=S.els[ac.mid];
811
  if(el){{
812
  var clipT=t-ac.start+ac.ts;
813
+ if(Math.abs(el.currentTime-clipT)>0.5)el.currentTime=clipT;
814
  el.volume=S.muted?0:ac.vol;
815
  if(S.playing&&el.paused)el.play().catch(function(){{}});
816
  if(!S.playing&&!el.paused)el.pause();