Double out animation playback

Hey guys,

I’m currently setting up some HTML templates, and we expect to need them for a certain amount of time, so have set the duration in the client, in our case for 8 seconds. However there is a small chance that we will need the playback to end early, so I was hoping I’d be able to simply clear this using F1. However, it seems that if I play another copy of the same template in the time remaining for this playback, it’s playing the out animation of that graphic on the new instance of that template, meaning it sometimes can instantly go back out again.

I cannot work out how to stop this from happening, does anyone have any ideas?

Thanks :slight_smile:

I’m not sure what duration in the client does but I’m guessing it will simply set a timeout to send a STOP command after the duration. That will fire no matter what you do in the mean time.

You might want to do most of this in your template with something like this:

var autoStop;
var onAir = 0;

function update() {
	if(onAir) {
	setTimeout(function() {
		// Do update stuff
		// You can call play() here if you just want to use UPDATE and STOP calls to control the template
	}, onAir * (2 * 1000) ); // If it takes two seconds to run your STOP stuff we'll let that run (because 1*2 = 2), otherwise it will happen straightaway (because 0*2 = 0)

function play() {
	onAir = 1;

	// Do play stuff

	autoStop = setTimeout(function() {
	}, 8 * 1000); // 8 seconds

function stop() {
	clearTimeout(autoStop); // In case there is a STOP call that isn't from the setTimeout

	// Do stop stuff

	onAir = 0;

Then you can simply control you template with UPDATEs and the occasional STOP.