Update html_helper.py
Browse files- html_helper.py +31 -11
html_helper.py
CHANGED
@@ -44,12 +44,12 @@ def create_html_from_midi(midifile):
|
|
44 |
|
45 |
/* Custom visualizer style */
|
46 |
#proll midi-visualizer .piano-roll-visualizer {{
|
47 |
-
background: #
|
48 |
border-radius: 0 0 8px 8px;
|
49 |
border: 1px solid #A0A0A0;
|
50 |
margin: 4px;
|
51 |
margin-top: 2;
|
52 |
-
overflow:
|
53 |
}}
|
54 |
|
55 |
#proll midi-visualizer svg rect.note {{
|
@@ -80,21 +80,41 @@ def create_html_from_midi(midifile):
|
|
80 |
</head>
|
81 |
<body>
|
82 |
<div>
|
83 |
-
<a href="{midifile}" target="_blank" style="font-size:
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
<
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
</div>
|
91 |
</body>
|
92 |
</html>
|
93 |
""".format(midifile=midifile)
|
94 |
-
html = f"""<
|
|
|
|
|
95 |
return html
|
96 |
|
97 |
def create_html_youtube_player(youtube_url):
|
98 |
youtube_url = to_youtube_embed_url(youtube_url)
|
99 |
-
html = f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
return html
|
|
|
|
44 |
|
45 |
/* Custom visualizer style */
|
46 |
#proll midi-visualizer .piano-roll-visualizer {{
|
47 |
+
background: #F7FAFA;
|
48 |
border-radius: 0 0 8px 8px;
|
49 |
border: 1px solid #A0A0A0;
|
50 |
margin: 4px;
|
51 |
margin-top: 2;
|
52 |
+
overflow: visible;
|
53 |
}}
|
54 |
|
55 |
#proll midi-visualizer svg rect.note {{
|
|
|
80 |
</head>
|
81 |
<body>
|
82 |
<div>
|
83 |
+
<a href="{midifile}" target="_blank" style="font-size: 14px;">Download MIDI</a> <br>
|
84 |
+
</div>
|
85 |
+
|
86 |
+
<div style="position: relative; width: 100%; height: 80%; display: flex; justify-content: center; align-items: center;">
|
87 |
+
<style>
|
88 |
+
#proll {{ width: 100%; height: 550px; transform: scaleY(0.8); transform-origin: top; transition: transform 0.3s ease; }}
|
89 |
+
@media (max-width: 500px) {{ #proll {{ transform: scaleY(0.7); }} }}
|
90 |
+
@media (max-width: 450px) {{ #proll {{ transform: scaleY(0.6); }} }}
|
91 |
+
@media (max-width: 400px) {{ #proll {{ transform: scaleY(0.5); }} }}
|
92 |
+
@media (max-width: 350px) {{ #proll {{ transform: scaleY(0.4); }} }}
|
93 |
+
@media (max-width: 300px) {{ #proll {{ transform: scaleY(0.3); }} }}
|
94 |
+
</style>
|
95 |
+
<section id="proll">
|
96 |
+
<midi-player src="{midifile}" sound-font="https://storage.googleapis.com/magentadata/js/soundfonts/sgm_plus" visualizer="#proll midi-visualizer"></midi-player>
|
97 |
+
<midi-visualizer src="{midifile}"></midi-visualizer>
|
98 |
+
</section>
|
99 |
</div>
|
100 |
</body>
|
101 |
</html>
|
102 |
""".format(midifile=midifile)
|
103 |
+
html = f"""<div style="display: flex; justify-content: center; align-items: center;">
|
104 |
+
<iframe style="width: 100%; height: 500px; overflow:visible" srcdoc='{html_template}'></iframe>
|
105 |
+
</div>"""
|
106 |
return html
|
107 |
|
108 |
def create_html_youtube_player(youtube_url):
|
109 |
youtube_url = to_youtube_embed_url(youtube_url)
|
110 |
+
html = f"""
|
111 |
+
<div style="display: flex; justify-content: center; align-items: center; position: relative; width: 100%; height: 100%;">
|
112 |
+
<style>
|
113 |
+
.responsive-iframe {{ width: 560px; height: 315px; transform-origin: top left; transition: width 0.3s ease, height 0.3s ease; }}
|
114 |
+
@media (max-width: 560px) {{ .responsive-iframe {{ width: 100%; height: 100%; }} }}
|
115 |
+
</style>
|
116 |
+
<iframe class="responsive-iframe" src="{youtube_url}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
117 |
+
</div>
|
118 |
+
"""
|
119 |
return html
|
120 |
+
|