Giter Site home page Giter Site logo

aadamsx / meteor-sounds Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adeubank/meteor-sounds

0.0 2.0 0.0 929 KB

A Meteor package to aid in pre-loading sound assets and playing audio files.

License: MIT License

CSS 0.91% HTML 18.33% JavaScript 80.76%

meteor-sounds's Introduction

MeteorSounds

A Meteor package to aid in pre-loading sound assets and playing audio files. Is built to work with Cordova and the low latency audio plugin. Provides methods to play, stop, and pre load all audio files. Perfect for games built on Meteor.

Install

meteor add adej:meteor-sounds

Usage

Meteor Sounds uses a method of low latency audio to preload audio files on apps built for Cordova. The plugin exposes a variable MeteorSounds to the platform web.cordova.

Include a settings.json file like so,

{
    "public" : {
        "sounds": {
            "soundFx" : {
                // sounds included in public directory are
                // added to the `application` directory
                // when building with cordova
                "soundId1" : "application/path/to/sound.wav"
            },
            "soundAudio" : {
                "soundId2" : "application/path/to/sound.wav"
            }
        }
    }
}

Then call,

MeteorSounds.preloadAllAssets();

Pairing with iron router, you can do something like this.

Router.route('/', {
  waitOn: function () {
    return function () {
      return MeteorSounds.assetsLoaded.get();
    }
  },
  action: function () {
    if (this.ready())
      this.render('home');
    else
      this.render('loading');
  }
});

Methods

Methods Description
MeteorSounds.preloadAllAssets() Preloads all audio files found in Meteor.setting.public.soundFx and Meteor.setting.public.soundAudio
MeteorSounds.play(sound) Plays an audio file whose id is sound
MeteorSounds.loop(sound) Loop an audio file whose id is sound
MeteorSounds.stop(sound) Stops an audio file whose id is sound

Properties

Properties Description
MeteorSounds.assetsLoaded ReactiveVar boolean that is set after all audio assets are loaded.

meteor-sounds's People

Contributors

adeubank avatar

Watchers

James Cloos avatar Aaron Adams 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.