Jian Short
Jian Short

Reputation: 135

Unable to pause the current sound and play next

I have a card matching game that I created here:

http://ewands.no-ip.biz/intern/guangjian/card/

The problem that I have is that I am unable to pause or mute the currently playing sound effect when a card is flipped, so if I immediately click the second card, no sound is heard. Using either pause and muted does not work. Any ideas?

//flipping_sound.pause(); does not work

//flipping_sound.muted; does not work

flipping_sound.play();

Upvotes: 0

Views: 57

Answers (2)

J261
J261

Reputation: 672

first you need to check if is playing with this:

function isPlaying(audioElement) { return audioElement.paused; }

and if the audio is playing you need change the position of the audio with this

function changeAudioPosition(audioElement) { audioElement.currentTime = 0; }

and if the audio is not playing just play again

Upvotes: 1

kpblc
kpblc

Reputation: 902

i'am using jquery and it's help for me:

flipping_sound.get(0).pause();
flipping_sound.get(0).currentTime = 0;
flipping_sound.get(0).play();

Upvotes: 1

Related Questions