Update app.py
Browse files
app.py
CHANGED
@@ -623,12 +623,75 @@ def create_interface():
|
|
623 |
"""
|
624 |
|
625 |
# HTML5 Audio Player 템플릿
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
632 |
"""
|
633 |
|
634 |
css = """
|
@@ -873,7 +936,16 @@ def create_interface():
|
|
873 |
온천천 온천장역에서 장전역까지 걸으며 더 깊은 체험이 가능합니다.
|
874 |
""")
|
875 |
|
876 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
877 |
|
878 |
with gr.Column():
|
879 |
reflection_input = gr.Textbox(
|
|
|
623 |
"""
|
624 |
|
625 |
# HTML5 Audio Player 템플릿
|
626 |
+
AUDIO_PLAYER_HTML = """
|
627 |
+
<div class="audio-player-container">
|
628 |
+
<audio id="mainAudio" preload="auto" style="display:none;">
|
629 |
+
<source src="/assets/main_music.mp3" type="audio/mp3">
|
630 |
+
</audio>
|
631 |
+
<button id="playButton" onclick="toggleAudio()" class="custom-audio-button">
|
632 |
+
<span id="playButtonText">재생</span>
|
633 |
+
</button>
|
634 |
+
</div>
|
635 |
+
<script>
|
636 |
+
let audio = document.getElementById('mainAudio');
|
637 |
+
let playButton = document.getElementById('playButton');
|
638 |
+
let playButtonText = document.getElementById('playButtonText');
|
639 |
+
|
640 |
+
function toggleAudio() {
|
641 |
+
if (audio.paused) {
|
642 |
+
audio.play().then(() => {
|
643 |
+
playButtonText.textContent = '일시정지';
|
644 |
+
}).catch(error => {
|
645 |
+
console.error('Audio playback failed:', error);
|
646 |
+
alert('음악 재생에 실패했습니다. 다시 시도해주세요.');
|
647 |
+
});
|
648 |
+
} else {
|
649 |
+
audio.pause();
|
650 |
+
playButtonText.textContent = '재생';
|
651 |
+
}
|
652 |
+
}
|
653 |
+
|
654 |
+
audio.addEventListener('ended', () => {
|
655 |
+
playButtonText.textContent = '재생';
|
656 |
+
});
|
657 |
+
|
658 |
+
audio.addEventListener('error', (e) => {
|
659 |
+
console.error('Audio error:', e);
|
660 |
+
alert('음악 파일을 불러오는데 실패했습니다.');
|
661 |
+
});
|
662 |
+
</script>
|
663 |
+
<style>
|
664 |
+
.audio-player-container {
|
665 |
+
margin: 20px 0;
|
666 |
+
width: 100%;
|
667 |
+
text-align: center;
|
668 |
+
}
|
669 |
+
.custom-audio-button {
|
670 |
+
width: 200px;
|
671 |
+
padding: 12px 24px;
|
672 |
+
margin: 10px 0;
|
673 |
+
background-color: #4a90e2;
|
674 |
+
color: white;
|
675 |
+
border: none;
|
676 |
+
border-radius: 8px;
|
677 |
+
cursor: pointer;
|
678 |
+
font-size: 16px;
|
679 |
+
font-weight: bold;
|
680 |
+
transition: background-color 0.3s ease;
|
681 |
+
}
|
682 |
+
.custom-audio-button:hover {
|
683 |
+
background-color: #357abd;
|
684 |
+
}
|
685 |
+
.custom-audio-button:active {
|
686 |
+
background-color: #2a5d8f;
|
687 |
+
transform: scale(0.98);
|
688 |
+
}
|
689 |
+
@media (max-width: 600px) {
|
690 |
+
.custom-audio-button {
|
691 |
+
width: 100%;
|
692 |
+
}
|
693 |
+
}
|
694 |
+
</style>
|
695 |
"""
|
696 |
|
697 |
css = """
|
|
|
936 |
온천천 온천장역에서 장전역까지 걸으며 더 깊은 체험이 가능합니다.
|
937 |
""")
|
938 |
|
939 |
+
# 커스텀 오디오 플레이어
|
940 |
+
with gr.Blocks(css=css) as demo:
|
941 |
+
gr.Markdown("## 온천천의 소리를 들어보세요")
|
942 |
+
# HTML로 오디오 플레이어를 직접 삽입
|
943 |
+
gr.HTML("""
|
944 |
+
<audio controls class="audio-player">
|
945 |
+
<source src="/assets/main_music.mp3" type="audio/mpeg">
|
946 |
+
브라우저가 오디오 태그를 지원하지 않습니다.
|
947 |
+
</audio>
|
948 |
+
""")
|
949 |
|
950 |
with gr.Column():
|
951 |
reflection_input = gr.Textbox(
|