get the audio player working on firefox
This commit is contained in:
parent
f895565fa9
commit
8c641ce662
6 changed files with 48 additions and 21 deletions
BIN
content/project/apollo/cover.png
Normal file
BIN
content/project/apollo/cover.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 166 B |
|
|
@ -4,4 +4,5 @@ date = "2025-05-25"
|
||||||
template = "song.html"
|
template = "song.html"
|
||||||
[extra]
|
[extra]
|
||||||
src = "apollo.mp3"
|
src = "apollo.mp3"
|
||||||
|
cover_src = "cover.png"
|
||||||
+++
|
+++
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ body {
|
||||||
body {
|
body {
|
||||||
background-color: c.$base;
|
background-color: c.$base;
|
||||||
}
|
}
|
||||||
h1, h2, h3, h4, h5, h6, p, a{
|
li, h1, h2, h3, h4, h5, h6, p, a{
|
||||||
color: c.$text;
|
color: c.$text;
|
||||||
font-family: "Source Code VF";
|
font-family: "Source Code VF";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@
|
||||||
font-weight: 200 900;
|
font-weight: 200 900;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-stretch: normal;
|
font-stretch: normal;
|
||||||
src: url('/font/WOFF2/VF/SourceCodeVF-Upright.ttf.woff2') format('woff2-variations'),
|
src: url('/font/source-code-pro/WOFF2/VF/SourceCodeVF-Upright.ttf.woff2') format('woff2-variations'),
|
||||||
url('/font/WOFF2/VF/SourceCodeVF-Upright.ttf.woff2') format('woff2 supports variations'),
|
url('/font/source-code-pro/WOFF2/VF/SourceCodeVF-Upright.ttf.woff2') format('woff2 supports variations'),
|
||||||
url('/font/WOFF/VF/SourceCodeVF-Upright.ttf.woff') format('woff-variations'),
|
url('/font/source-code-pro/WOFF/VF/SourceCodeVF-Upright.ttf.woff') format('woff-variations'),
|
||||||
url('/font/WOFF/VF/SourceCodeVF-Upright.ttf.woff') format('woff supports variations'),
|
url('/font/source-code-pro/WOFF/VF/SourceCodeVF-Upright.ttf.woff') format('woff supports variations'),
|
||||||
url('/font/VF/SourceCodeVF-Upright.ttf') format('truetype-variations'),
|
url('/font/source-code-pro/VF/SourceCodeVF-Upright.ttf') format('truetype-variations'),
|
||||||
url('/font/VF/SourceCodeVF-Upright.ttf') format('truetype supports variations');
|
url('/font/source-code-pro/VF/SourceCodeVF-Upright.ttf') format('truetype supports variations');
|
||||||
}
|
}
|
||||||
|
|
||||||
@font-face{
|
@font-face{
|
||||||
|
|
@ -22,10 +22,10 @@
|
||||||
font-weight: 200 900;
|
font-weight: 200 900;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
font-stretch: normal;
|
font-stretch: normal;
|
||||||
src: url('/font/WOFF2/VF/SourceCodeVF-Italic.ttf.woff2') format('woff2-variations'),
|
src: url('/font/source-code-pro/WOFF2/VF/SourceCodeVF-Italic.ttf.woff2') format('woff2-variations'),
|
||||||
url('/font/WOFF2/VF/SourceCodeVF-Italic.ttf.woff2') format('woff2 supports variations'),
|
url('/font/source-code-pro/WOFF2/VF/SourceCodeVF-Italic.ttf.woff2') format('woff2 supports variations'),
|
||||||
url('/font/WOFF/VF/SourceCodeVF-Italic.ttf.woff') format('woff-variations'),
|
url('/font/source-code-pro/WOFF/VF/SourceCodeVF-Italic.ttf.woff') format('woff-variations'),
|
||||||
url('/font/WOFF/VF/SourceCodeVF-Italic.ttf.woff') format('woff supports variations'),
|
url('/font/source-code-pro/WOFF/VF/SourceCodeVF-Italic.ttf.woff') format('woff supports variations'),
|
||||||
url('/font/VF/SourceCodeVF-Italic.ttf') format('truetype-variations'),
|
url('/font/source-code-pro/VF/SourceCodeVF-Italic.ttf') format('truetype-variations'),
|
||||||
url('/font/VF/SourceCodeVF-Italic.ttf') format('truetype supports variations');
|
url('/font/source-code-pro/VF/SourceCodeVF-Italic.ttf') format('truetype supports variations');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,31 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@use '_icons';
|
||||||
|
|
||||||
|
|
||||||
|
main {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
#player {
|
#player {
|
||||||
margin: auto;
|
padding-bottom: 50px;
|
||||||
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#cover {
|
||||||
|
padding-top: 35px;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 300px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
#title {
|
#title {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
@ -21,20 +39,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#playbutton {
|
#playbutton {
|
||||||
width: 8%;
|
width: 15%;
|
||||||
|
max-width: 65px;
|
||||||
aspect-ratio: 1/1;
|
aspect-ratio: 1/1;
|
||||||
margin-right: 15px;
|
margin-right: min(15px, 2%);
|
||||||
background: #313244;
|
background: #313244;
|
||||||
border: none;
|
border: none;
|
||||||
color: #cba6f7;
|
color: #cba6f7;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
line-height: 100%;
|
line-height: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-size: min(8cqw, 40px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.seek {
|
.seek {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
margin-left: 15px;
|
margin-left: min(15px, 2%);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@
|
||||||
{% endblock title %}
|
{% endblock title %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="player">
|
<div id="player">
|
||||||
|
{% if page.extra.cover_src %}
|
||||||
|
<img id="cover" src="{{ page.extra.cover_src }}"/>
|
||||||
|
{% endif %}
|
||||||
{% if page.extra.cover %}
|
{% if page.extra.cover %}
|
||||||
<img id="cover" src="{{ page.extra.cover }}"/>
|
<img id="cover" src="{{ page.extra.cover }}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -15,7 +18,7 @@
|
||||||
{{ page.title }}
|
{{ page.title }}
|
||||||
</h1>
|
</h1>
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<button id="playbutton">▶</button>
|
<button id="playbutton" class="material-symbols-sharp">play_arrow</button>
|
||||||
<input type="range" class="seek" id="seek" max="1" value="0" step="0.001">
|
<input type="range" class="seek" id="seek" max="1" value="0" step="0.001">
|
||||||
</div>
|
</div>
|
||||||
<audio id="audio" controls src="{{ page.extra.src }}" style="display:none" preload="metadata">
|
<audio id="audio" controls src="{{ page.extra.src }}" style="display:none" preload="metadata">
|
||||||
|
|
@ -27,16 +30,16 @@
|
||||||
const audio = document.getElementById("audio");
|
const audio = document.getElementById("audio");
|
||||||
const playbutton = document.getElementById("playbutton");
|
const playbutton = document.getElementById("playbutton");
|
||||||
const seek = document.getElementById("seek");
|
const seek = document.getElementById("seek");
|
||||||
seek.value = 0.0;
|
|
||||||
let playing = false;
|
let playing = false;
|
||||||
|
seek.value = 0.0;
|
||||||
|
|
||||||
playbutton.addEventListener("click", () => {
|
playbutton.addEventListener("click", () => {
|
||||||
if (playing) {
|
if (playing) {
|
||||||
audio.pause();
|
audio.pause();
|
||||||
playbutton.textContent = "▶";
|
playbutton.textContent = "play_arrow";
|
||||||
} else {
|
} else {
|
||||||
audio.play();
|
audio.play();
|
||||||
playbutton.textContent = "⏸";
|
playbutton.textContent = "pause";
|
||||||
}
|
}
|
||||||
playing = !playing;
|
playing = !playing;
|
||||||
});
|
});
|
||||||
|
|
@ -47,7 +50,10 @@
|
||||||
|
|
||||||
seek.addEventListener("change", () => {
|
seek.addEventListener("change", () => {
|
||||||
audio.currentTime = audio.duration * seek.value;
|
audio.currentTime = audio.duration * seek.value;
|
||||||
|
const progress = (audio.currentTime / audio.duration);
|
||||||
|
seek.value = progress;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue