Youngsun Lim commited on
Commit
2e13497
Β·
1 Parent(s): d521b9d

no sound videos2

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py CHANGED
@@ -369,6 +369,40 @@ html, body, .gradio-container { background: transparent !important; }
369
 
370
  # -------------------- UI --------------------
371
  with gr.Blocks(fill_height=True, css=GLOBAL_CSS) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  order_state = gr.State(value=[]) # v4μ—μ„œλŠ” value= ꢌμž₯
373
  ptr_state = gr.State(value=0)
374
  cur_video_id = gr.State(value="")
 
369
 
370
  # -------------------- UI --------------------
371
  with gr.Blocks(fill_height=True, css=GLOBAL_CSS) as demo:
372
+ # Blocks μ•ˆ, μ–΄λ””μ„œλ“  ν•œ 번만 μΆ”κ°€(ꢌμž₯ μœ„μΉ˜: Blocks μ‹œμž‘ 직후)
373
+ gr.HTML("""
374
+ <script>
375
+ (function(){
376
+ function muteAll(root){
377
+ const vids = (root || document).querySelectorAll('video');
378
+ vids.forEach(v => {
379
+ try {
380
+ v.muted = true;
381
+ v.volume = 0.0;
382
+ v.setAttribute('muted','');
383
+ // μ‚¬μš©μžκ°€ μ‹€μˆ˜λ‘œ 킀더라도 λ‹€μ‹œ 0으둜
384
+ v.addEventListener('volumechange', () => {
385
+ if (!v.muted || v.volume > 0) { v.muted = true; v.volume = 0.0; }
386
+ });
387
+ } catch(e){}
388
+ });
389
+ }
390
+ // 초기 λ Œλ”μ—μ„œ μŒμ†Œκ±°
391
+ muteAll(document);
392
+ // 이후 동적 μƒμ„±λ˜λŠ” λΉ„λ””μ˜€λ„ κ°μ‹œν•΄μ„œ μŒμ†Œκ±°
393
+ const obs = new MutationObserver(muts => {
394
+ for (const m of muts) {
395
+ if (m.type === 'childList') {
396
+ muteAll(m.target);
397
+ m.addedNodes && m.addedNodes.forEach(n => muteAll(n));
398
+ }
399
+ }
400
+ });
401
+ obs.observe(document.body, {subtree:true, childList:true});
402
+ })();
403
+ </script>
404
+ """)
405
+
406
  order_state = gr.State(value=[]) # v4μ—μ„œλŠ” value= ꢌμž₯
407
  ptr_state = gr.State(value=0)
408
  cur_video_id = gr.State(value="")