haepada commited on
Commit
03598da
·
verified ·
1 Parent(s): bc3c19e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -72
app.py CHANGED
@@ -599,9 +599,10 @@ def create_interface():
599
  print(f"이미지 로딩 에러 ({image_path}): {e}")
600
  return ""
601
 
602
- # 로고 이미지 인코딩
603
  mobile_logo = encode_image_to_base64("static/DIGITAL_GUTPAN_LOGO_m.png")
604
  desktop_logo = encode_image_to_base64("static/DIGITAL_GUTPAN_LOGO_w.png")
 
605
 
606
  if not mobile_logo or not desktop_logo:
607
  logo_html = """
@@ -616,75 +617,35 @@ def create_interface():
616
  """
617
 
618
  # HTML5 Audio Player 템플릿
 
 
 
 
 
619
  AUDIO_PLAYER_HTML = """
620
  <div class="audio-player-container">
621
- <audio id="mainAudio" preload="auto" style="display:none;">
622
- <source src="/assets/main_music.mp3" type="audio/mp3">
 
623
  </audio>
624
- <button id="playButton" onclick="toggleAudio()" class="custom-audio-button">
625
- <span id="playButtonText">재생</span>
626
- </button>
627
  </div>
628
- <script>
629
- let audio = document.getElementById('mainAudio');
630
- let playButton = document.getElementById('playButton');
631
- let playButtonText = document.getElementById('playButtonText');
632
-
633
- function toggleAudio() {
634
- if (audio.paused) {
635
- audio.play().then(() => {
636
- playButtonText.textContent = '일시정지';
637
- }).catch(error => {
638
- console.error('Audio playback failed:', error);
639
- alert('음악 재생에 실패했습니다. 다시 시도해주세요.');
640
- });
641
- } else {
642
- audio.pause();
643
- playButtonText.textContent = '재생';
644
- }
645
- }
646
-
647
- audio.addEventListener('ended', () => {
648
- playButtonText.textContent = '재생';
649
- });
650
-
651
- audio.addEventListener('error', (e) => {
652
- console.error('Audio error:', e);
653
- alert('음악 파일을 불러오는데 실패했습니다.');
654
- });
655
- </script>
656
  <style>
657
  .audio-player-container {
658
- margin: 20px 0;
659
  width: 100%;
 
 
660
  text-align: center;
661
  }
662
- .custom-audio-button {
663
- width: 200px;
664
- padding: 12px 24px;
665
- margin: 10px 0;
666
- background-color: #4a90e2;
667
- color: white;
668
- border: none;
669
- border-radius: 8px;
670
- cursor: pointer;
671
- font-size: 16px;
672
- font-weight: bold;
673
- transition: background-color 0.3s ease;
674
- }
675
- .custom-audio-button:hover {
676
- background-color: #357abd;
677
- }
678
- .custom-audio-button:active {
679
- background-color: #2a5d8f;
680
- transform: scale(0.98);
681
  }
682
  @media (max-width: 600px) {
683
- .custom-audio-button {
684
  width: 100%;
685
  }
686
  }
687
- </style>
688
  """
689
 
690
  css = """
@@ -863,11 +824,7 @@ def create_interface():
863
  with gr.Tabs(selected=0) as tabs:
864
  # 입장 탭 (축원 포함)
865
  with gr.TabItem("입장") as tab_entrance:
866
- gr.HTML("""
867
- <div class="main-image-container">
868
- <img src="static/main-image.png" alt="디지털 굿판 메인 이미지" class="main-image">
869
- </div>
870
- """)
871
  # 1단계: 첫 화면
872
  welcome_section = gr.Column(visible=True)
873
  with welcome_section:
@@ -935,12 +892,7 @@ def create_interface():
935
  with gr.Blocks(css=css) as demo:
936
  gr.Markdown("## 온천천의 소리를 들어보세요")
937
  # HTML로 오디오 플레이어를 직접 삽입
938
- gr.HTML("""
939
- <audio controls class="audio-player">
940
- <source src="/assets/main_music.mp3" type="audio/mpeg">
941
- 브라우저가 오디오 태그를 지원하지 않습니다.
942
- </audio>
943
- """)
944
 
945
  with gr.Column():
946
  reflection_input = gr.Textbox(
@@ -1023,11 +975,7 @@ def create_interface():
1023
  wrap=True
1024
  )
1025
  with gr.TabItem("프로젝트 소개") as tab_intro:
1026
- gr.HTML("""
1027
- <div class="main-image-container">
1028
- <img src="static/main-image.png" alt="디지털 굿판 메인 이미지" class="main-image">
1029
- </div>
1030
- """)
1031
  gr.Markdown("""
1032
  # 디지털 굿판 프로젝트
1033
  ‘디지털 굿판’은 부산문화재단의 지원으로 루츠리딤이 제작한 다원예술 프로젝트입니다.
 
599
  print(f"이미지 로딩 에러 ({image_path}): {e}")
600
  return ""
601
 
602
+ # 이미지 인코딩
603
  mobile_logo = encode_image_to_base64("static/DIGITAL_GUTPAN_LOGO_m.png")
604
  desktop_logo = encode_image_to_base64("static/DIGITAL_GUTPAN_LOGO_w.png")
605
+ main_image = encode_image_to_base64("static/main-image.png")
606
 
607
  if not mobile_logo or not desktop_logo:
608
  logo_html = """
 
617
  """
618
 
619
  # HTML5 Audio Player 템플릿
620
+ main_image_html = """
621
+ <div class="main-image-container">
622
+ <img src="data:image/png;base64,{main_image}" alt="디지털 굿판 메인 이미지" class="main-image">
623
+ </div>
624
+ """
625
  AUDIO_PLAYER_HTML = """
626
  <div class="audio-player-container">
627
+ <audio controls class="audio-player">
628
+ <source src="/assets/main_music.mp3" type="audio/mpeg">
629
+ 브라우저가 오디오 태그를 지원하지 않습니다.
630
  </audio>
 
 
 
631
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
  <style>
633
  .audio-player-container {
 
634
  width: 100%;
635
+ max-width: 800px;
636
+ margin: 20px auto;
637
  text-align: center;
638
  }
639
+ .audio-player {
640
+ width: 100%;
641
+ max-width: 300px;
642
+ margin: 0 auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  }
644
  @media (max-width: 600px) {
645
+ .audio-player {
646
  width: 100%;
647
  }
648
  }
 
649
  """
650
 
651
  css = """
 
824
  with gr.Tabs(selected=0) as tabs:
825
  # 입장 탭 (축원 포함)
826
  with gr.TabItem("입장") as tab_entrance:
827
+ gr.HTML(main_image_html)
 
 
 
 
828
  # 1단계: 첫 화면
829
  welcome_section = gr.Column(visible=True)
830
  with welcome_section:
 
892
  with gr.Blocks(css=css) as demo:
893
  gr.Markdown("## 온천천의 소리를 들어보세요")
894
  # HTML로 오디오 플레이어를 직접 삽입
895
+ gr.HTML(AUDIO_PLAYER_HTML)
 
 
 
 
 
896
 
897
  with gr.Column():
898
  reflection_input = gr.Textbox(
 
975
  wrap=True
976
  )
977
  with gr.TabItem("프로젝트 소개") as tab_intro:
978
+ gr.HTML(main_image_html)
 
 
 
 
979
  gr.Markdown("""
980
  # 디지털 굿판 프로젝트
981
  ‘디지털 굿판’은 부산문화재단의 지원으로 루츠리딤이 제작한 다원예술 프로젝트입니다.