Play HTML template without reloading

Hey all! I had a quick question regarding HTML templates.
Is there a way to keep the template on after the STOP command? I’m building a small template that I’d like to fade in and out (with some CSS magic); however, the page reloads when I play it.
Thank you!

You must be doing something to destroy it after STOP. Are you calling window.remove() on STOP?

I am not sure I understand it, but why you don;t use the INVOKE command for calling some JavaScript function of the template. The template remains playing and you can make everything with the template via called JS function (for instance add class for show, hide, udpate texts, animate something etc.) You can even send parameters (ideally in JSON format) to the function.

Humm, what version of CCG are you running? HTML templates are not destroyed on STOP for me (I have to add window.remove() for that).

I’ve gone over the source and STOP will not destroy the HTML instance running the template. It needs to be implemented in javascript with window.close(). It’s the same way for Flash templates; the templatehost (which is the Flash file that load the template) implements it’s own destruction.

1 Like

Oh, CasparCG Client calls CG ADD instead of CG PLAY upon pressing F2. It makes sense, but I’m curious if there’s a way to play the template in CasparCG Client without regenerating it. Maybe I’ll give the Custom Command thing a try.

Sorry for the work you put into this. Maybe I’ll give up live production and join up with a circus :grinning: (Rocky III reference) I’m still a high school student, so I have plenty of time to learn how to use this amazing software :grin:

Thank you for your time!

You have UPDATE, PLAY, STOP, NEXT and INVOKE.

The simplest option is to just think of PLAY and STOP as SHOW and HIDE. You change data via UPDATE.

You could implement something like:
< style >
body { opacity: 0; }
.show { opacity: 1; }
< /style >
< script >
function play() {
document.getElementsByTagName(‘body’)[0].classList.add(‘show’);
}

function stop() {
document.getElementsByTagName('body')[0].classList.remove('show');
}
< /script >

Also remember that CG ADD always calls UPDATE and then PLAY if play-on-load.

The issue is that CG ADD reloads the template prior to playing it. I’m wondering if CasparCG Client has a CG PLAY command of some sort.

if your template is already loaded then you can invoke any function you want like @hreinnbeck said above

CG 1-1 INVOKE 1 “YourFunction”

Sorry, I’m not explaining this well. I’m not having issues with the server, I just have a question about the client. I’m trying to invoke the play() function from CasparCG Client. I can do it just fine from the command window.

When I select the template a press F2 in CasparCG Client, it reloads the template before playing it.

alright !!
in client ‘PLAY F2’ will load and play template.
if you want to load and play on separate trigger then first load your template with ‘Load F3’ then use ‘Invoke F7’ with your defined invoke function like PLAY.

F3 loads the template and F2 plays a loaded template. If the template is not loaded, than F2 loads & plays it.

So here’s my problem. F2 is loading the template even if it’s already loaded.

You are right, that is something weird in HTML templates as described in indr’s very good tutorial if you read down to the paragraph about CG ADD. So what you could try is set a variable in your javascript code, that you set, when you only want to load and prevents a section of the code to run.

By the way: For this kind of scenarios, were a template needs to be run all time and only is hidden from view, I use two functions show() and hide() that I can call with CG INVOKE and only do the animation. You can call them from play() and stop() also for start and end, but call them directly to show/hide the graphic without unloading. I do this for scorebugs in sports, were I want to be able to always update the clock and the scores regardless if the bug is visible or not.

The only problem is the CCG Client.

Just did tests with 2.1 and 2.2 as well as double checking source code. Play on load is handled correctly for HTML in all cases:

Should play-on-load:
CG 1-20 ADD 1 “TESTHTML” 1 “DATA”
[CONSOLE] “update called”
[CONSOLE] “play called”

Should NOT play-on-load:
CG 1-20 ADD 1 “TESTHTML” 0 “DATA”
[CONSOLE] “update called”

Also for those who do not know. If you haven’t loaded/F3 a template before play/F2 - the client will always do a CG ADD. The client always sends a play-on-load in those cases, and there doesn’t seem to be anything exposed in the GUI to toggle it.