1.0.10 • Published 6 years ago

ambienx v1.0.10

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Ambienx (BackgroundMusic.js)

Use some background music to give your website or webapp some ambience.

var newAmbienx = new Ambienx({
    audioSrc: 'music.mp3',
    audioLoop: false,
    autoPlay: false,
    enabledLoseFocus: true
});

Play

document.querySelector('.play-audio').addEventListener('click', function() {
    newAmbienx.playAudio();
}, false);

Pause

document.querySelector('.pause-audio').addEventListener('click', function() {
    newAmbienx.pauseAudio();
}, false);

Stop

document.querySelector('.stop-audio').addEventListener('click', function() {
    newAmbienx.pauseAudio({stop: true});
}, false);

Fade In

This method accepts an integer argument (1-10), which controls the target fade volume.

document.querySelector('.fade-in-audio').addEventListener('click', function() {
    newAmbienx.fadeInAudio(1, function() {
        <!-- execute callback code here -->
    });
}, false);

Fade Out

This method accepts an integer argument (1-10), which controls the target fade volume. If the target fade volume is not 0, then the audio will keep playing.

document.querySelector('.fade-out-audio').addEventListener('click', function() {
    newAmbienx.fadeOutAudio(0, function() {
        <!-- execute callback code here -->
    });
}, false);

Toggle Fade

This method accepts an argument that is an object, which controls the fade in and fade out volume.

document.querySelector('.toggle-fade-audio').addEventListener('click', function() {
    newAmbienx.toggleFadeAudio({
        fadeInVolume: 1,
        fadeOutVolume: 0
    });
}, false);
1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago