Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

webyarns/webyarns-sounds

Repository files navigation

Project

Init

The sound needs to be initialised by a user-gesture (e.g., touch event).

Here's an example HTML:

<section data-disable-keyboard data-prevent-swipe>
    <h1><a id="init-sounds" href="#">click here to start</a></h1>
    <div id="sound-loader">
        <!-- anything here will be shown during the initialisation -->
        <div class="loader-pulsing-dot"></div>
    </div>
</section>

then use the following javascript (place this after loading Reveal)

WebyarnsSounds.init({
    initElement: document.getElementById("init-sounds"),
    loaderElement: document.getElementById("sound-loader")
}).then(() => {
    Reveal.next() // proceed to next section
})

Some details:

  • Options:
    • initElement: element that when clicked will start the loading of audio. This element will also disappear when clicked
    • loaderElement: element to show when initialisation has started
  • WebyarnsSounds.init returns a promise. It is completed when the sounds have been loaded.

Usage

Sound API:

  • data-sounds with operators::
    • «id»: no operator: continue sound from previous slide (if still playing)
    • !«id»: restart a sound
    • >«id»: start persistently (needs to be stopped using #)
    • #«id»: stop a persistently started audio
  • data-sounds-volume-change change volume (syntax: id:volume, where volume is between 0 and 1)
  • data-fade-in-speed and data-fade-out-speed

Dev setup

$ yarn install --ignore-engines

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published