Public
Edited
Dec 25, 2022
1 fork
3 stars
Insert cell
Insert cell
viewof playButton = Inputs.button("Play")
Insert cell
Insert cell
song = FileAttachment("SoundHelix-Song-1.mp3")
Insert cell
Insert cell
audioElement = {
const url = await song.url();
return html`<audio src="${ url }" crossorigin="anonymous"></audio>`
}
Insert cell
Insert cell
audioContext = {
const context = new AudioContext();
const track = context.createMediaElementSource(audioElement);
track.connect(context.destination);
return context;
}
Insert cell
Insert cell
{
if (playButton > 0) {
if (audioContext.state === "suspended") audioContext.resume();
if (audioElement.paused) audioElement.play()
else audioElement.pause();
}
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more