Détail du package

ion-sound

IonDen1.7kMIT3.0.7

JavaScript plugin for playing sounds and music in web

sound, sounds, web, audio

readme

ion.sound

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

JavaScript plugin for playing sounds on user actions and page events.


Description

  • Ion.Sound — JavaScript-plugin for playing sounds based on Web Audio API.
  • Plugin is working on most popular desktop and mobile browsers and can be used everywhere, from common web sites to browser games.
  • For not so modern browsers plugin falls back to HTML5 audio.
  • Audio-sprites support included.
  • Ion.Sound freely distributed under terms of MIT licence.
  • 25 free sounds included

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. Also, new version of Ion.Sound is capable to handle browser games audio. It has full control of loading, playing and removing audio files. And audio-sprites support of course.

Supported browsers

Desktop Windows, OS X, Linux:

  • Google Chrome
  • Mozilla Firefox
  • Microsoft Internet Explorer 9.0+
  • Opera 12.16+
  • Safari 5.1+ (Safari on Windows requires QuickTime to play sounds)

Mobile:

  • iOS Safari and others (with some restrictions)
  • Android Google Chrome and others (with some restrictions also)
  • WP8 Internet Explorer

Can i use Web Audio API and HTML5 Audio?

Demos

Dependencies

  • None

Usage

Import this library:

  • 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
  • my_cool_sound.aac

It is not enough to have only MP3-file, you should make OGG and AAC-file too, because not all browsers support MP3.
You can easily convert you MP3-s to OGG-s and AAC-s at Media.io or at CloudConvert.org.
AAC support was added to improve cross browser support of iOS 8.x devices (iPhone, iPad)

Install with bower

  • bower install ionsound

Install with npm

  • npm install ion-sound

Install with spm

  • spm install ion-sound

Initialisation

To initialise plugin call this method:

ion.sound({
    sounds: [
        {
            name: "my_cool_sound"
        },
        {
            name: "notify_sound",
            volume: 0.2
        },
        {
            name: "alert_sound",
            volume: 0.3,
            preload: false
        }
    ],
    volume: 0.5,
    path: "sounds/",
    preload: true
});

And play sound!

// Simple
ion.sound.play("my_cool_sound");

General settings

Option Defaults Type Description
sounds - array Collection of sound objects. Each object contains information about sound file and (optional) individual settings
path - string Path to file
preload false boolean Preloading sounds
multiplay false boolean Sound multi play. If set, will allow to play multiple instances of one sound at once
loop false boolean/number If set to true will enable infinite loop. Or paste a number to set loop limit
volume 1.0 number Playback volume from 0 to 1
scope null object Callbacks will be called in that object's scope
ready_callback null function Called after sound file is fully uploaded (or ready to play for HTML5 audio)
ended_callback null function Called each time then sound file will reach it's end

Sound object

Option Defaults Type Description
name - string File name. Plugin will choose file extension automatically (.mp3, .ogg, .aac, .mp4 and etc.)
alias - string Alias for sound call, optional. Normally is used to shorten ion.sound calls
sprite - object Mark that sound is audio-sprite. This is an object. Example: {"part_name_1": [0, 2], "part_name_2": [2, 2]}
Part_name is a name of sprite piece (it is used instead of name to play a sound). And array with time marks: [start, duration] in seconds.
And also individual: path, preload, multiplay, loop, volume, scope and callbacks

Plugin can be launched in jQuery namespace

  • Use aliases to call any plugin methods: ion.sound(); -> $.ionSound();
  • ion.sound.play("sound_name"); -> $.ionSound.play("sound_name");
  • Etc.

Update history


Support Ion-series plugins development:

changelog

Ion.Sound Update History

Version 3.0.7. March 06, 2016

  • Fixed bug #71

Version 3.0.6. August 04, 2015

  • Fixed bug #49
  • Attempt to fix #35

Version 3.0.5. July 27, 2015

  • Fixed bug #44

Version 3.0.4. June 04, 2015

  • Version jump to fix nmp
  • Fixed bug #42

Version 3.0.1. May 29, 2015

  • Master volume added. Issues: #28, #38
  • Fixed bugs #30, #31

Version 3.0.0. February 10, 2015

  • New Web Audio API core
  • HTML5 fallback remastered
  • Audio sprites support
  • Advanced preloading controls
  • Normal callbacks support
  • Removed jQuery dependency

Version 2.1.3. October 29, 2014

  • Fixed some minor bugs in Firefox and MS IE

Version 2.1.2. October 26, 2014

  • Minor fix for iOS 8.x

Version 2.1.1. October 25, 2014

  • Minor fix

Version 2.1.0. October 25, 2014

  • AAC files support
  • Minor bug fixes
  • Callback "onEnded"
  • SPM support

Version 2.0.2. August 08, 2014

  • New pause method
  • Bower support

Version 2.0.1. August 01, 2014

  • 2 versions of plugin, jQuery and Vanilla JS

Version 2.0.0. June 31, 2014

  • New API
  • Sound loop option

Version 1.3.0. November 30, 2013

  • Method "stop"
  • Method "kill"
  • Volume control added to "play" method

Version 1.2.0. October 13, 2013

  • Individual volume for any sound
  • Improved test environment

Version 1.1.0. September 21, 2013

  • Plugin moved to jQuery namespace
  • New method
  • 10 new free sounds

Version 1.0.1. September 08, 2013

  • Bug fix in iOS

Version 1.0.1. September 08, 2013

  • Little enhancement

Version 1.0.0. September 07, 2013

  • Plugin release