sofie-casparcg-server icon indicating copy to clipboard operation
sofie-casparcg-server copied to clipboard

HTML producer: Add window.casparcg and change user agent

Open hreinnbeck opened this issue 6 years ago • 3 comments

Change the CEF user agent to "CasparCG Video and Graphics Playout Server VERSION". This could be used in server generated applications to check if they should render for Caspar or a browser.

Created windows.casparcg object.

I would appreciate help with hooking HTML up with AMCP and OSC.

Future ideas:

  • Return channel and layer that HTML is running on (so you can easily automate templates without knowing chan/layer (like playing a video on the layer beneath: window.casparcg.amcp('PLAY '+window.casparcg.channel+'-'+(window.casparcg.layer-1)+' AMB LOOP');

  • Return framerate for animations that depend on fps for durations (don't confuse with tick we already have, that doesn't help a template that should be able to run 1 sec animation irrespective of the framerate

  • Return paths (window.casparcg.media, .template, .font, .data, .log, .thumbnail etc.) [all should be relative and users could use window.casparcg.initialpath to create a full path]

hreinnbeck avatar Dec 24 '18 00:12 hreinnbeck

Thanks, this is a good start. I'll wait until its a bit more filled out before merging though. Also the future ideas all sound like good things to do

I am thinking that instead of sending OSC directly, it would be better to set fields on a state object. That avoids one off messages, and lets the template expose constant data better and will translate quite cleanly to how 2.2 works with osc data internally.

I'm also not entirely sure about changing the user agent. I'm not sure if it will be a real problem, but it will confuse some websites that do feature detection based on browser agent. It would be safer to just append a bit to the end, so it becomes something like Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36 CasparCG/2.1.0NRK

Julusian avatar Jan 28 '19 17:01 Julusian

Thanks Julian. Haven't had much time to spend on this since the holidays.

I have OSC output functioning (though I haven't had time to finish the casting required, e.g. everything is sendt as strings at the moment). I'll look into having a state object modifiable from JS. My current workflow is to send data from JS on requestanimation, so it is continuous and isn't sent too often.

I'll change the user agent so it just adds CCG version info.

Currently logging information is also hooked up to JS but I haven't made any progress with OSC input and AMCP.

hreinnbeck avatar Jan 29 '19 06:01 hreinnbeck

love to see window.casparcg.amcp and osc in action. it will make lots of work very quick and easy as @hreinnbeck saying in future ideas.

currently i'm sending amcp command from js to webserver then it is sending back to server on socket for playing something.

sirfnomi avatar Mar 03 '20 22:03 sirfnomi