I am trying to make a toggle play function, using an if statement. I use the .paused method/property to checking if the element is playing. My problem is that the property returns true even if the audio is playing. Here's my code:
var player = $("#player");
var playerE = $("#player")[0];
var playerE = $("#player").get(0);
var isPaused = playerE.paused;
function togglePlay() {
if (isPaused === false) {
player.trigger("pause");
} else {
player.trigger("play");
}
}
Here's my audio element too:
If you need to test it out, Here's a snippet:
var player = $("#player");
var playerE = $("#player")[0];
var playerE = $("#player").get(0);
var isPaused = playerE.paused;
function togglePlay() {
if (isPaused === false) {
player.trigger("pause");
} else {
player.trigger("play");
}
}
/** Added for testing **/
function check() {
alert(isPaused);
}
Check isPlaying
As you can see, it returns true even if the audio IS playing. What is going on here? Is this a bug?