mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig.space.git
synced 2025-12-14 16:56:50 +00:00
Share soundboard URLs
This commit is contained in:
@@ -7,7 +7,13 @@ block vars
|
|||||||
block main
|
block main
|
||||||
#soundboard.wrap
|
#soundboard.wrap
|
||||||
script.
|
script.
|
||||||
window.player = { songs: [], continue_next: false };
|
window.player = { songs: [], continue_next: false, autoplay: true };
|
||||||
|
window.playSound = index => {
|
||||||
|
Amplitude.playSongAtIndex(index)
|
||||||
|
const { url } = Amplitude.getSongAtIndex(index)
|
||||||
|
const [, slug] = url.match(/^\/sounds\/(.*)\.mp3$/)
|
||||||
|
window.location.hash = slug
|
||||||
|
}
|
||||||
section
|
section
|
||||||
h1= title
|
h1= title
|
||||||
.player.player--soundboard
|
.player.player--soundboard
|
||||||
@@ -38,5 +44,13 @@ block main
|
|||||||
each sound in group.sounds
|
each sound in group.sounds
|
||||||
script.
|
script.
|
||||||
window.player.songs.push({ album: '#{group.title}', name: '#{sound.title.replace("'", "\\'")}', url: '#{sound.file}' })
|
window.player.songs.push({ album: '#{group.title}', name: '#{sound.title.replace("'", "\\'")}', url: '#{sound.file}' })
|
||||||
button.button(type="button" onclick=`Amplitude.playSongAtIndex(${index})`)= sound.title
|
button.button(type="button" onclick=`playSound(${index})`)= sound.title
|
||||||
- index++
|
- index++
|
||||||
|
script.
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const { hash } = window.location
|
||||||
|
if (hash) {
|
||||||
|
const index = Amplitude.getSongs().findIndex(sound => sound.url === `/sounds/${hash.substring(1)}.mp3`)
|
||||||
|
if (index > -1) playSound(index)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user