Giter VIP home page Giter VIP logo

soundy-example's Introduction

Soundy

A simply library using the Audio API

Currently baked into an expres app to get play with the API and load files without XSS issues.

Actually implementation file in /public/javascripts/index.js

Include soundy

Include soundy.js (my modular approach)

<script type='text/javascript' src='/javascripts/modules/soundy/index.js'>

Define the options object to pass into Soundy

Options (object)
- Sounds (array of 'sound' objects)
-- filename (name of the file)
-- name (your 'name' for the file)
- Path (the url path to your sounds folder)
var options = {
  sounds: [
    {
        filename: 'YourSound1.wav',
        name: 'Sound1'
    }
  ],
  path: '/audio/' // Defaults to /audio/
}

Load your sounds & other options

soundy.load(options, function (err, loaded) {
  if (err) {
    console.error(err)
  } else {
    console.log(loaded) // All the sounds have loaded, you're good to go
  }
})

Play a sound

To play a sound, you pass the name into the play function, also provided as a sounds object.

NB. This needs to be done, after the soundy.load call back

Method 1: The object (available via the JavaScript console)

soundy.play(soundy.sounds.Sound1)

Method 2: Pass a string name

soundy.play('Sound1')

Get the Soundy Version No.

You can get the soundy version no., by calling it in your code, or via a JavaScript console with

soundy.version

soundy-example's People

Contributors

mrdnk avatar

Stargazers

David Corking avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.