How can we pass data to HTML template in loadbg?


is it possible to call a html template on background layer ?

LOADBG 1-1 “html”
CAL 1-1 “update(‘aasd’);”
PLAY 1-1

or is it possible to send data with loadbg command ?

LOADBG 1-1 “html” “data”
PLAY 1-1

I don’t think there is a way currerntly.
Could you make it so that the page is empty and transparent when loaded, so you can PLAY it instead of LOADBG, then you can can CALL on it to start the content.

If someone is up for doing it, it would be fairly simply to add a CALLBG command, its mostly going to be some copy and paste to implement the amcp command and expose the needed method

1 Like

i don’t know about C++ otherwise i would have done it.
well thank you Julusian for explaining :+1:

Can you not use CG ADD? That usually also works for HTML templates. You can also use an URL instead of the template name. SPX does it that way.

Actually I am using background layer to load the HTML template. it is suitable for switching templates on same layer without any delay.

It will be much easier, faster and smoother for live production if we are able to pass data to the HTML template with the loadbg command.

But CG ADD does load the template to the background layer. You need to set the
play-on-load argument to 0 (false) for this to work. It then can be played with a CG PLAY. To play a template directly set play-on-load to 1 and don’t use the CG PLAY command.

That is the standard way of doing it, why would you want to do it the other way around?

i think i have not been able to explain my point to you properly. i try to explain it properly.

let’s suppose play 1-1 "html1" is running and when we send loadbg 1-1 "html2" command to server, it will load html2 on background and html1 is still running on foreground at layer 1 of channel 1.
and when we send play 1-1 then it will destroy html1 and show html2 from background to foreground at layer 1 of channel 1.
In this way our html2 template is loaded and ready.

but CG ADD with play-on-load to 0 command directly load template on foreground, it just not fire play() method of javascript. so in this case it will destroy html1.

That is not true. This is from the doc of the CG ADD command

CG [video_channel:int]{-[layer:int]|-9999} ADD [cg_layer:int] [template:string] [play-on-load:0,1] {[data]}

There is that play-on-load argument, that needs to be set to zero to load in the background. Then you send a CG STOP to the one visible and a CG PLAY to show the loaded template. It works exactly the same as the LOAD, PLAY and STOP commands for video, except that you can give data to it. If the programming library, that you use does not support CG ADD with autoplay disabled, then your library is false.

Didikunz you are mixing play-on-load with load in background but they are different things.

if you send CG 1 ADD 1 "template1" 0 "data" then server will load template1 on CG Layer 1 and with CG 1 PLAY 1 server will trigger play() method of template1.
but when you send CG 1 ADD 1 "template2" 0 "data" then server will destroy template1 and load template2.
for testing you can manually send these commands to server.

and Yes you are right we should request for CG 1 ADDBG command to developers instead of LOADBG with data arguments because LOAD PLAY STOP is for media and CG is for templates.

Good that you knows better than me. It seems, that I don‘t know much about CasparCG. I only work nearly 10 years with it. In such a short time, one cannot learn anything. So, if you know it better, then do what you want and feel sad, that it does not work the way you think it should.

I wish you a merry christmas and a happy new year. Don’t expect any more help of me.

i think i understand what you try to say noumaan. but i am afraid that the html producer is not made with a background layer… Probally one of the developers can say more about this. i guess you want to setup a new template on the same layer while the other is stilll vissible right ?

I have learned a lot from you and you have helped me many times, please don’t think like that.

If this could be implemented “no clue” one question too ask is what should be done with the “old” template when you want to show the new ?

What is your working condition the standard client / your own software or something else.

Yes, I was thinking that it would be possible somehow.

Actually with the help of background layer it is easy to change templates without any loading delay or black on screen

I’m using my own client and I’m syncing black magic atem output with casparcg templates

Sorry, the whole discussion is useless, because it is already in Caspar. It is the CG ADD command that can load a template in the background, just read the wiki and try it out, if you don’t believe.

We do not need to implement something, that is already available, just because someone is not willing to read the wiki.

Ok did not know that i was not sure if the html producer had a background layer or if it is destroying as noumaan is saying. I use a different workflow normally soo i just don’t know. I was seeing a discussion and tried to think along. I guess something is not working in the workflow / end result Noumaan is trying to achieve other wise this question would not be asked. Probally a way to do this is by loading the template once and do the logic noumaan needs inside the template instead of in caspar. … there are soo many way’s you could do this.

ok out of curiousity i quickly tested it.


cg 1-20 add 1 "URL" 0 

indeed destroys the “old” producer.

well at least with the latests build.

this is what the wiki is saying

actually the wiki is not saying it is loading in the background.

the wiki says it is not showing when firing the command,
it is not mentioning what it does with the template all ready there.

things can be interpret different sometimes.

please keep discusion constructive.

even going a bit further the wiki
does not even reflect the way the producer really works.

a random common webpage like google will still show with the play on load on 0

i don’t want to call this a useless discussion

Ok, it seems the only idiot in this tread is me. Sorry and my apologies.

The funny thing is, that I tested it yesterday and it worked. What I did not realize is, that I tested with old Flash templates. That is why I was 100% sure, that it is possible. Now I tried again and I now saw, that it is not possible in HTML as the second CG ADD on the same layer kills the output.

Sorry for all anger and misunderstanding.

The solution to seamless transition two HTML templates would be to use two layers and play the first template on the first layer and load (CG ADD with play-on-load off) the second template on the second layer. Then issue a CG STOP for the first and a CG PLAY for the second template at the same time.


No issue didikunz :slight_smile:
Thank you Maurice for understanding and testing this.