i wonder what i\'m doing wrong?
$(\'.player_audio\').click(function() {
if ($(\'.player_audio\').paused == false) {
$(\'.player_audio\').paus
Because Firefox does not support mp3 format. To make this work with Firefox, you should use the ogg format.
Here is my solution using jQuery
<script type="text/javascript">
$('#mtoogle').toggle(
function () {
document.getElementById('playTune').pause();
},
function () {
document.getElementById('playTune').play();
}
);
</script>
And the working demo
http://demo.ftutorials.com/html5-audio/
Simply Use
$('audio').trigger('pause');
This thread was quite helpful. The jQuery selector need to be told which of the selected elements the following code applies to. The easiest way is to append a
[0]
such as
$(".test")[0].play();
Here is my solution (if you want to click another element on the page):
$("#button").click(function() {
var bool = $("#player").prop("muted");
$("#player").prop("muted",!bool);
if (bool) {
$("#player").prop("currentTime",0);
}
});
Well, I'm not 100% sure, but I don't think jQuery extends/parses those functions and attributes (.paused
, .pause()
, .play()
).
try to access those over the DOM element, like:
$('.player_audio').click(function() {
if (this.paused == false) {
this.pause();
alert('music paused');
} else {
this.play();
alert('music playing');
}
});