Stopping one sound clip from playing when another one starts.

Hello,


I've figured out how to have a text block display (click - show - text block) and a sound clip play (show - Play - sound clip) when someone clicks a picture. There will be about 4 pictures on the page. As soon as they click a different picture, the sound clip from the first picture should stop playing. Does anyone know how this is done?


Thanks!

Discussion (9)

@TTT 57293 wrote:

Hello,


I've figured out how to have a text block display (click - show - text block) and a sound clip play (show - Play - sound clip) when someone clicks a picture. There will be about 4 pictures on the page. As soon as they click a different picture, the sound clip from the first picture should stop playing. Does anyone know how this is done?


Thanks!


If I understand what you want then you can do this with actions. When you click on the picture you can have a "Stop" action whose target is one of the audio files. Have one stop action for each of the three audio files that may be playing.

@TTT 57293 wrote:

Hello,


I've figured out how to have a text block display (click - show - text block) and a sound clip play (show - Play - sound clip) when someone clicks a picture. There will be about 4 pictures on the page. As soon as they click a different picture, the sound clip from the first picture should stop playing. Does anyone know how this is done?


Thanks!



So you have 2 actions:

Click - Show picture 1

Click - Play sound 1


You have to add more.

First pic:

Click - Show picture 1

Click - Play sound 1

Click - Stop sound 2

Click - Stop sound 3

Click - Stop sound 4


Second pic:

Click - Show picture 2

Click - Play sound 2

Click - Stop sound 1

Click - Stop sound 3

Click - Stop sound 4


Etc.

If each of your images has a different audio clip or if your dealing with a lot of audio on one screen what I prefer to do is make an action group titled something like "Silence All". In that group put an option to Stop each of the audio files. That way when that action group is run it stops all audio.


Then you can just two actions for each graphic.

On Click> Run Action Group> Silence All

On Click>Play >Image 1 audio



...etc.

There is an alternative technique as well.


1. Add 4 audio clips to the page.

2. Delete 3 of them.

3. On each button, add following actions:

- on Click - change contents of "sound1.mp3" to "sound1.mp3"

- on Click - change contents of "sound1.mp3" to "sound2.mp3"

- on Click - change contents of "sound1.mp3" to "sound3.mp3"

- on Click - change contents of "sound1.mp3" to "sound4.mp3"


Set all sounds to autoplay. Now when you click the button, the previous sound is stopped and replaced by the new sound. No need to create all those extra "stop sound X" actions. I tested, it worked as expected on PC with voice at autostart ON.

I find it best to put all actions to stop all audio / hide all pop-up/rollover images etc into one action group. this makes it easier to re-use for each iteration of the buttons on the page. i.e.


Group_stop:

- stop audio 1

- stop audio 2

- stop audio 3

- stop audio 4

- hide image 1

- hide image 2

- hide image 3

- hide image 4

(could use hide 'group_images' here instead if all pop-up images were added to a group)


Then on button 1 (to play audio 1/show image 1) i would have the following:

- run action group > group_stop

- play audio 1

- show image 1


button 2 would be:

- run action group > group_stop

- play audio 2

- show image 2


etc etc

SSNeg, your method is interesting. I guess the only thing that may get confusing is that you can't see the audio file names associated with the page in the Title Explorer.

ha! oh yeah - i see you pretty much said the same thing above :)

I am new to Lectora and I just wanted to say thanks for the advice on how to handle this. Very clear instructions and easy to implement.

I always follow this method:


Click - Show picture 1

Click - Stop sound 2

Click - Stop sound 3

Click - Stop sound 4

Click - Play sound 1


I stop everything before I start what the user should hear. But I kind of like the "replace" option that ssneg mentioned. Might try that next time! :o

Discussions have been disabled for this post