Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML producer: Add window.casparcg and change user agent #14

Draft
wants to merge 1 commit into
base: 2.1.x
Choose a base branch
from

Conversation

hreinnbeck
Copy link

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.

<script> // This can be used for dev/production checking: if(window.casparcg) { console.log('We are running in Caspar'); } else { console.log('We are running in a browser'); } console.log('window.casparcg.fullversion: '+window.casparcg.fullversion); // Returns string: CasparCG Video and Graphics Playout Server 2.1.0.10254 38d4e64 NRK console.log('window.casparcg.version: '+JSON.stringify(window.casparcg.version)); // Returns object: {"name":"CasparCG Video and Graphics Playout Server","general":2,"major":1,"minor":0,"tag":"NRK","revision":10254,"hash":"38d4e6478"} console.log('window.casparcg.amcp("PLAY 1-10 AMB") '+window.casparcg.amcp('PLAY 1-10 AMB')); // AMCP NOT IMPLEMENTED YET console.log('window.casparcg.osc("/html/status","updating"): '+window.casparcg.osc('/html/status','updating')); // OSC NOT IMPLEMENTED YET </script>

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]

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.

<script>
// This can be used for dev/production checking:
if(window.casparcg) {
	console.log('We are running in Caspar');
} else {
	console.log('We are running in a browser');
}

console.log('window.casparcg.fullversion: '+window.casparcg.fullversion);
// Returns string: CasparCG Video and Graphics Playout Server 2.1.0.10254 38d4e64 NRK

console.log('window.casparcg.version: '+JSON.stringify(window.casparcg.version));
// Returns object: {"name":"CasparCG Video and Graphics Playout Server","general":2,"major":1,"minor":0,"tag":"NRK","revision":10254,"hash":"38d4e6478"}

console.log('window.casparcg.amcp("PLAY 1-10 AMB") '+window.casparcg.amcp('PLAY 1-10 AMB'));
// AMCP NOT IMPLEMENTED YET

console.log('window.casparcg.osc("/html/status","updating"): '+window.casparcg.osc('/html/status','updating'));
// OSC NOT IMPLEMENTED YET
</script>

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]
@Julusian
Copy link
Member

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

@hreinnbeck
Copy link
Author

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.

@sirfnomi
Copy link

sirfnomi commented Mar 3, 2020

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.

@Julusian Julusian marked this pull request as draft May 13, 2020 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants