Skip to content

brunolight/ion.sound

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ion.Sound 1.3.0

English description | Описание на русском

Plugin for playing sounds on events.


Description

  • Crossbrowser support: Google Chrome, Mozilla Firefox, Opera, Safari, IE(9.0+) and mobile browsers
  • GitHub Page.
  • Ion.Sound freely distributed under terms of MIT licence.
  • Ion.Sound includes 25 free sounds

Today websites are full of events (new mail, new chat-message, content update etc.). Often it is not enough to indicate this events only visually to get user attention. You need sounds! This library, made for playing small sounds, will help you with this task.

Dependencies

Usage

Import this libraries:

  • jQuery
  • ion.sound.min.js

Prepare sound-files (25 sounds are included) and put them in some folder (eg. "sounds"):

  • my_cool_sound.mp3
  • my_cool_sound.ogg

It is not enough to have only Mp3-file, you should make Ogg-file too, because not all browsers support Mp3.
You can easily convert you Mp3-s to Ogg-s at Media.io or at CloudConvert.org.

Initialisation

To initialise plugin call this method:

$.ionSound({
    sounds: [
        "my_cool_sound"
    ]
});

And play sound!

$.ionSound.play("my_cool_sound");

Settings

Settings Default Description
sounds ["water_droplet:0.5"] Optional property, you can set your own sounds collection here. It is array.
:0.5 - optional individual volume. Example: sound_name:0.2
path "static/sounds/" Optional property, set path to folder with sounds.
multiPlay true Optional property, if set to false, will allow plugin to play only 1 sound at once.
volume 0.5 Optional property, will set base volume from 0.0 to 1.0

An example of a customised plugin:

$.ionSound({
    sounds: [                       // set needed sounds names
        "beer_can_opening",
        "bell_ring:0.3",            // :0.3 - individual volume
        "branch_break",
        "metal_plate",
        "pop_cork:0.8",             // :0.8 - individual volume
        "staple_gun",
        "water_droplet:0.4"         // :0.4 - individual volume
    ],
    path: "sounds/",                // set path to sounds
    multiPlay: false,               // playing only 1 sound at once
    volume: "0.3"                   // not so loud please
});

Methods

Playing sound:

$.ionSound.play("button_tiny");

// For example playing sound on button click

$("#myButton").on("click", function(){
    $.ionSound.play("button_tiny");
});

// or reset the sound volume

$("#myButton").on("click", function(){
    $.ionSound.play("button_tiny:0.5");
});

Stop sound playback:

$.ionSound.stop("button_tiny");

Remove sound from memory:

$.ionSound.kill("button_tiny");

Destroying the plugin:

$.ionSound.destroy();

Update history

  • November 30, 2013 - new methods "stop" and "kill". Ability to reset sound volume.
  • October 13, 2013 - now you can set individual volume for any sound. Improved test environment.
  • September 21, 2013 - plugin moved to jQuery namespace, new method and 10 new sounds
  • September 08, 2013 - iOS not playing sound bug fix
  • September 08, 2013 - Little enhancement
  • September 07, 2013 - Plugin release

About

jQuery-plugin for playing sounds on events

Resources

Stars

Watchers

Forks

Packages

No packages published