Hello, my friends!

In 4.3.7 I'm added new component AudioButton and method Metro.playSound.

With method Metro.playSound, you can play any sounds on your request.

var btn = document.querySelector(...);
car sound = 'https://website.com/sound.mp3';
btn.addEventListener('click', e => {
    Metro.playSound(sound, (src) => {
        console.log('sound '+src+' done')
    })
})

or, You can create button (or other element) with role audio-button.

<button class="button" data-audio-src="https://website.com/sound.mp3">
    Play sound
</button>

Example on codepen.io

See the Pen YzywgWb by Sergey Pimenov (@olton) on CodePen.light

Last modified: 16.04.2020

Author

Comments

Write a Reply or Comment

Your email address will not be published.