Action to stop ALL media
January 16, 2016 12:00 AM
Hello
In Lectora 12 is there a way to code an action so that it stops all or any media which are playing? I do not want to specify the media to be stopped every time.
Thank you
Andrew
Discussion (4)
Something like this?
name: 'clicky',
src : 'assets/audio/button-30.mp3',
}
var coiny = {
name: 'coiny',
src : 'assets/audio/mario-coin.mp3',
}
var ambient = {
name: 'ambient',
src : 'assets/audio/MattOglseby7.mp3',
}
var slidy = {
name: 'slidy',
src : 'assets/audio/windowslide.mp3',
}
var soundsArr = [clicky,coiny,ambient,slidy];
var SoundsModule = {};
_.each(soundsArr,function(el){
var a = el;
SoundsModule[a.name] = new Audio;
SoundsModule[a.name].src = a.src;
});
_.extend(SoundsModule,{
muteAll:function(){
_.each(soundsArr,function(el){
var a = el;
SoundsModule[a.name]
SoundsModule[a.name].muted = true;;
});
}
});
Thank you everyone. That is very helpful.
Cheers
Andrew
If you just want to stop all media, you can use jQuery in a "Run javascript" action on a button:
On: Click
Action: Run javascript
Javascript:
$("div[id*='audio'],div[id*='video']").each(
function(){
aydee = $(this).attr("id");
window[aydee].actionStop();
});
The button can be placed on title level and will stop all audio and video files on the current page that have been inserted using the normal Lectora dialogue by using Lectora's native "Stop" action.
Tim
P.S. Tested in Lectora v11 only
Discussions have been disabled for this post