Ion.Sound Demo Page

Feedback and support

If you find some bugs or missing functional in plugins, use Issues page on GitHub

Support

Support ion.RangeSlider «Patreon»
Bitcoin 13vdgT6EoAVupdGuLhE4ABW245NTixAj1G

Adv

Ion.Sound customizing demos

Simple start and customising basic params

// init bunch of sounds
ion.sound({
    sounds: [
        {name: "beer_can_opening"},
        {name: "bell_ring"},
        {name: "branch_break"},
        {name: "button_click"}
    ],

    // main config
    path: "static/sounds/",
    preload: true,
    multiplay: true,
    volume: 0.9
});

// play sound
ion.sound.play("beer_can_opening");
While starting ion.sound, you can set up the default config for all included sounds. It is ok, then all sounds are in one directory and should be play with the same volume.
Name: beer_can_opening Loaded:
Play once
Name: bell_ring Loaded:
Play once
Name: branch_break Loaded:
Play once
Name: button_click Loaded:
Play once

Individual config for each sound

ion.sound({
    sounds: [
        {
            // individual config
            name: "button_click_on",
            path: "sounds/group1/",
            volume: 0.3
        },
        {
            name: "button_push",
            path: "sounds/group2/",
            volume: 0.6
        },
        {
            name: "button_tiny",
            preload: false
        },
        {
            name: "camera_flashing",
            multiplay: false,
            preload: false
        }
    ],

    // main config
    path: "sounds/",
    preload: true,
    multiplay: true
});

// play sound
ion.sound.play("button_click_on");
In more complex situations, you can set individual config for every included sound you want. Individual config will override the default one. This is helpful then you store your sounds in different directories and/or want to play them with different volume and etc.
Name: button_click_on Loaded:
Play once
Name: button_push Loaded:
Play once
Name: button_tiny Loaded:
Load and play
Name: camera_flashing Loaded:
Load and play
Name: all
Play and stop all sounds

Extra config on using play method

ion.sound({
    sounds: [
        {name: "camera_flashing_2"},
        {name: "cd_tray"},
        {name: "computer_error"},
        {name: "door_bell"}
    ],

    // main config
    path: "static/sounds/",
    preload: true,
    multiplay: true,
    volume: 0.1 // default volume is 10%
});

// overriding volume in methods
ion.sound.play("camera_flashing_2", {
    volume: 1.0
});
ion.sound.play("cd_tray", {
    volume: 0.7
});
ion.sound.play("computer_error", {
    volume: 0.5
});
ion.sound.play("door_bell", {
    volume: 0.2
});
Even more! You can override individual configs by new ones each time you use "play" method. In this example, we will override the default volume value by new one, each time we pressing play button.
Name: camera_flashing_2 Loaded:
Play once with volume 1.0
Name: cd_tray Loaded:
Play once with volume 0.7
Name: computer_error Loaded:
Play once with volume 0.5
Name: door_bell Loaded:
Play once with volume 0.2

Aliases and loops

ion.sound({
    sounds: [
        {
            alias: "s1",
            name: "door_bump"
        },
        {
            alias: "s2",
            name: "glass"
        },
        {
            alias: "s3",
            name: "keyboard_desk",
            loop: 3
        },
        {
            alias: "s4",
            name: "light_bulb_breaking",
            loop: true
        }
    ],

    path: "static/sounds/",
    preload: false,
    volume: 1
});

ion.sound.play("s1", {
    loop: 7
});
ion.sound.play("s2", {
    loop: 5
});
ion.sound.play("s3");
ion.sound.play("s4");

// Set master volume
ion.sound.volume({volume: 0.5});
Alias is a shorter name for the sound, you wish to play. With alias param you can easily turn long name "computer_alert_beep_sound" in to short "beep".
Loop is a param to repeat sound N times. For example set it to 10 and sound will be repeated for 10 times, or set it to "true" for infinity.
Name: door_bump Alias: s1 Loaded:
Loop 7 times
Name: glass Alias: s2 Loaded:
Loop 5 times
Name: metal_plate Alias: s3 Loaded:
Loop 3 times
Name: light_bulb_breaking Alias: s4 Loaded:
Loop for infinity
Change master volume

Playback

ion.sound({
    sounds: [
        {name: "witchdoctor"}
    ],

    path: "static/sounds/",
    preload: false,
    multiplay: false,
    volume: 1
});

// play, pause and stop
ion.sound.play("witchdoctor");
ion.sound.pause("witchdoctor");
ion.sound.stop("witchdoctor");
Controlling playback is easy. You have 3 methods for that: play, pause and stop. Just call method with sound name and it will work: ion.sound.play("witchdoctor"). If you will call this methods without params, like this: ion.sound.play(), it will try to play, pause or stop all(!) connected sounds.
Be aware of multiplay param with long sounds or music files. If set to true, it will allow plugin to create any number of audio instances and you will able to control only the last one.
Name: witchdoctor Loaded:
Play a song and control playback
Fork me on GitHub