Stopping then playing the same audio clip

mlapl1 Community Member Posts: 349 ☆ Roadie ☆
There must be a simple way of doing this but, unexpectedly, it does not work

I want students to play an audio clip. At the moment if they multiple click the play button I have created, they will initiate multiple plays of the clip simultaneously e.g. they click three times on the button, they will hear 3 playbacks all offset in relation to one another - very messy.


I wrote this

onmclick stop clip
onmclick play clip

I would expect this to stop the clip if it is playing, then play the clip.

BUT... that does not work and nothing is played. Nothing happens.

I suppose I could disable/hide the button until the clip is played etc. but that would add a complication and also force the student to listen to the entire clip (unless I create a stop button etc.). I could just use a toggle but would prefer to start playback from the beginning. I could show a player but would prefer not to.

There must be a way of doing this simply without resorting to JS. Seems like a lot of trouble but maybe there is no option.

Thanks for any thoughts.


  • mlapl1
    mlapl1 Community Member Posts: 349 ☆ Roadie ☆
    ok. I fixed it by toggling a variable - but it seems like a lot of work for something that should be quite simple - and I have to re-link a file several times (unless I use a change contents strategy).
  • jasonadal
    jasonadal Community Member Posts: 441 ♪ Opening Act ♪
    Hi Andrew - With all the work I've been doing to get audio to play the ways I want to, I could take a look at a sample if you have one and work something out. The unfortunate piece is that most of the solutions I've had to use do involve JavaScript (see my post about playing specific sections based on user clicks).
  • timk
    timk Community Member Posts: 1,205 ♦ Idol ♦
    Is there anything else happening with the audio on that page or with the button? Which version do you have? I tested a button to "Stop" and "Play" and it's working without issues, i.e. always playing the audio from the beginning, in Lectora 17.1.3 and 16.1.2.

    Try to put a short delay on the "Play" action, in case the Stop command isn't finished before the "Play" comes.