mbostock / stack

A presentation library with intuitive, scroll-based navigation.
https://mbostock.github.io/stack/
Other
1.16k stars 163 forks source link

Associate sound tracks to the slides. #9

Closed drio closed 10 years ago

drio commented 10 years ago

Hi @mbostock ,

I wanted to associate explanations to my slides so I added sound support to stack.

When loading, stack tries to pull the sound associated to each slide. The convention is pretty straight forward; sounds have to be under sounds/ and have to be named: (\d+).mp3, where (\d+) is the number of the slide. Right now the user can play the sound for a slide hitting the s key. When transitioning between slides the sound will stop.

The component that implements all the sound logic is pretty self-contained. I have minimally modified stack.js to add the necessary calls to the sound component.

You can see all these in action here. Warning: I have only added sounds to the first three slides.

If you find this interesting I can prepare a pull request. Let me know,

-drd

mbostock commented 10 years ago

You should be able to do this using activate / deactivate events.

drio commented 10 years ago

Sounds are triggered when user presses 's' and stopped if they transition to another slide while the sound is still playing.

I thought that would be better than firing up the sound automatically for each slide. This way the user can decide when to play the sound.

drio commented 10 years ago

I have released the extension here. Just in case you want to reference it in your README. Thanks again for the help.