I have an event where I need to play a mp3/wav sound every time a certain condition is verified. Is there a way to play it cross-browser, also even if I open android browser on a tablet?
Actually I am using a javascript plugin called ionSound but looks like it doesn't work under android's tabled..
Like:
jQuery.ajax({
type: "GET",
dataType: "json",
url: "./getData.php?idx="+id,
success: function(data) {
if (data.length > 0) {
// alert('Gotta play sound...');
dataFound = true;
$.ionSound({
sounds: [ "woop_woop" ],
path: "../../images/"
});
$.ionSound.play("woop_woop");
// alert('Played sound right now...');
} else {
dataFound = false;
}
}
});
Thanks in advance to all!
Cheers, Luigi
I'm picking back this question again... I figured out on some platforms it doesn't really play sound... for example on another desktop PC with Chrome it doesn't play audio, neither on another tablet...I think it's due of browser's version... so is there a pure javascript way to just play an audio like a little mp3 or wav from code?..
Thanks in advance! Cheers Luigi
Create an Audio
object and play
it!
The link Audio
takes in the constructor may be from any source.
var audio = new Audio('audio_file.mp3');
audio.play()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With