haepada commited on
Commit
5e0c9e4
·
verified ·
1 Parent(s): 4709eba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -3
app.py CHANGED
@@ -616,16 +616,17 @@ def create_interface():
616
  # HTML5 Audio Player 템플릿
617
  AUDIO_PLAYER_HTML = """
618
  <div class="audio-player-container">
619
- <audio id="mainAudio" preload="auto" style="width: 100%;">
620
  <source src="/assets/main_music.mp3" type="audio/mp3">
621
  Your browser does not support the audio element.
622
  </audio>
623
  <button id="playButton" onclick="togglePlay()" class="custom-audio-button">
624
- 재생/일시정지
625
  </button>
626
  </div>
627
  <script>
628
  let audioElement = document.getElementById('mainAudio');
 
629
  let isPlaying = false;
630
 
631
  function togglePlay() {
@@ -633,6 +634,7 @@ def create_interface():
633
  audioElement.play()
634
  .then(() => {
635
  isPlaying = true;
 
636
  })
637
  .catch(error => {
638
  console.error("Audio playback failed:", error);
@@ -641,6 +643,7 @@ def create_interface():
641
  } else {
642
  audioElement.pause();
643
  isPlaying = false;
 
644
  }
645
  }
646
 
@@ -658,6 +661,38 @@ def create_interface():
658
  alert("음악 파일을 불러오는데 실패했습니다. 페이지를 새로고침해주세요.");
659
  });
660
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661
  """
662
 
663
  css = """
@@ -778,7 +813,7 @@ def create_interface():
778
  온천천 온천장역에서 장전역까지 걸으며 더 깊은 체험이 가능합니다.
779
  """)
780
 
781
- # 커스텀 오디오 플레이어로 교체
782
  gr.HTML(AUDIO_PLAYER_HTML)
783
 
784
  with gr.Column():
@@ -1086,6 +1121,7 @@ def create_interface():
1086
  inputs=[final_reflection, state],
1087
  outputs=[baseline_status, wishes_display]
1088
  )
 
1089
  return app
1090
 
1091
  if __name__ == "__main__":
 
616
  # HTML5 Audio Player 템플릿
617
  AUDIO_PLAYER_HTML = """
618
  <div class="audio-player-container">
619
+ <audio id="mainAudio" preload="auto">
620
  <source src="/assets/main_music.mp3" type="audio/mp3">
621
  Your browser does not support the audio element.
622
  </audio>
623
  <button id="playButton" onclick="togglePlay()" class="custom-audio-button">
624
+ <span id="playButtonText">재생</span>
625
  </button>
626
  </div>
627
  <script>
628
  let audioElement = document.getElementById('mainAudio');
629
+ let playButtonText = document.getElementById('playButtonText');
630
  let isPlaying = false;
631
 
632
  function togglePlay() {
 
634
  audioElement.play()
635
  .then(() => {
636
  isPlaying = true;
637
+ playButtonText.textContent = '일시정지';
638
  })
639
  .catch(error => {
640
  console.error("Audio playback failed:", error);
 
643
  } else {
644
  audioElement.pause();
645
  isPlaying = false;
646
+ playButtonText.textContent = '재생';
647
  }
648
  }
649
 
 
661
  alert("음악 파일을 불러오는데 실패했습니다. 페이지를 새로고침해주세요.");
662
  });
663
  </script>
664
+ <style>
665
+ .audio-player-container {
666
+ margin: 20px 0;
667
+ width: 100%;
668
+ text-align: center;
669
+ }
670
+ .custom-audio-button {
671
+ width: 200px;
672
+ padding: 12px 24px;
673
+ margin: 10px 0;
674
+ background-color: #4a90e2;
675
+ color: white;
676
+ border: none;
677
+ border-radius: 8px;
678
+ cursor: pointer;
679
+ font-size: 16px;
680
+ font-weight: bold;
681
+ transition: background-color 0.3s ease;
682
+ }
683
+ .custom-audio-button:hover {
684
+ background-color: #357abd;
685
+ }
686
+ .custom-audio-button:active {
687
+ background-color: #2a5d8f;
688
+ transform: scale(0.98);
689
+ }
690
+ @media (max-width: 600px) {
691
+ .custom-audio-button {
692
+ width: 100%;
693
+ }
694
+ }
695
+ </style>
696
  """
697
 
698
  css = """
 
813
  온천천 온천장역에서 장전역까지 걸으며 더 깊은 체험이 가능합니다.
814
  """)
815
 
816
+ # 커스텀 오디오 플레이어
817
  gr.HTML(AUDIO_PLAYER_HTML)
818
 
819
  with gr.Column():
 
1121
  inputs=[final_reflection, state],
1122
  outputs=[baseline_status, wishes_display]
1123
  )
1124
+
1125
  return app
1126
 
1127
  if __name__ == "__main__":