It is currently 24 Jun 2017, 08:08



Please - a simple basic tutorial

Moderators: Macey, Jonas Hummelstrand, didikunz

Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 08:09

I've hunted the forum and the web, and keep finding the same questions asked but never answered properly, so please could someone who knows, post for all of us who have endlessly searched and failed......

I've build a lower thirds client in LiveCode. I need to get the two lines of text to appear over my Flash template. I can do this in the supplied CasparCG client, now I want to do it in my client.

I've read and re-read the protocol pages, especially CG ADD etc. Here's the example given there -
CG 1 ADD 10 svtnews/info 1. Unfortunately meaningless. It mentions "a reference to a saved dataset" ....

How do I save a dataset?
Should the saved set be in straight xml like the <templateData> example or does it need the escaped version?
How do I reference it in the CD ADD command?
Is it quicker on-air to have saved the data earlier or send with the command from Livecode?

Please - a simple tutorial rather than references to other posts or projects would help me, and, as it turns out, lots of other people

Thank you

Bernard Newnham
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby didikunz » 02 Aug 2016, 09:06

To do a good tutorial one needs to have a good knowledge of the issue and plenty of time to wtrite or record it. And it only covers a linited topic. Therefore it is practically impossible to do tutorials for all given programming languages, like LiveCoce, VB.NET, C#, Adobe Air etc. So I am afraid you will not get a turorial very soon. What you find in the forum here are guys, that developed clients in LiveCode and already shared some source code. You can ask questions in these treads and will get answers to specific questions for sure.

To start with what you asked about the protocoll page and datasets: For normal client programming you seldom use the datasets. So you safely an ignore anything about them.

They were invented for the case (that SVT has) when you have a huge studio automation system, that fires up graphics in Caspar and the data is not present when the rundown is created beforehand. Then the rundown firees a graphic that uses a dataset created by another programm in the background. That can be used for stock or wheather data. There is an extra section in the wiki about the data commands.

To come back to the normal way of doing it: The template data is an XML tree. It has to be encoded as UTF-8 and some characters have to be escaped, as said in the wiki section you mentioned. I do not know much about LiveCode and in the FAQ section of the forum here, there is no library to send data to LiveCode. Would need some kind of sub-stack, I guess. You can ask in the LiveCode threads here in the forum for one, if it exists.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 10:10

The problem I'm having with Livecode is that back and forward slashes are significant in strings, and now I seem to be escaping escape codes, which isn't too helpful.

So - I thought that if I can send the xml data separately, as the wiki mentions, I could make life easier. But the DATA STORE command didn't seem to do anything, and even if the data was a standard <templateData> xml file copied into the server data folder there's no reference on how to use it in a CG ADD command. Which is why I asked the questions.

Thanks for answering - it's a start....

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby didikunz » 02 Aug 2016, 10:28

bern333 wrote:The problem I'm having with Livecode is that back and forward slashes are significant in strings, and now I seem to be escaping escape codes, which isn't too helpful.


There must be a way of doing this properly. And you need the same thing to issue a DATA STORE. So this is something you should find in a LiveCode related thread (or what about the forum on LiveCode's site?)

bern333 wrote:So - I thought that if I can send the xml data separately, as the wiki mentions, I could make life easier. But the DATA STORE command didn't seem to do anything, and even if the data was a standard <templateData> xml file copied into the server data folder there's no reference on how to use it in a CG ADD command. Which is why I asked the questions.


As first argument you give the DATA STORE a name for the dataset. On the CG ADD you use this name at the place you would put the XML string with the data.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 10:31

On the CG ADD you use this name at the place you would put the XML string with the data.


That's what i thought, but I have no proper reference for the actual command structure that gives me a CG ADD including the separate dataset

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby didikunz » 02 Aug 2016, 10:48

You can try:

Code: Select all
CG 1-1 ADD 1 nameOfTheTemplate 1 nameOfTheDataset
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 11:03

Thank you, I will
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 11:31

Well, that certainly found the data file. Thanks.

Sadly it failed with a Flash 1090 error, even though I did a straight rip off of the example -

<templateData><componentData id=\"f0\">
<data id=\"text\" value=\"Niklas P Andersson\">
</data> </componentData><componentData id=\"f1\">
<data id=\"text\" value=\"developer\">
</data></componentData></templateData>
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby mcdikki » 02 Aug 2016, 12:07

Btw: There is a very good reference for each ccg command in the wiki.
http://www.casparcg.com/wiki/CasparCG_2.0_AMCP_Protocol

Actually, you don't need much more than this page and some knowledge how to use socket networking in live code to get your client running.

Cheers
mcdikki
sublan.tv - Wir teilen Begeisterung
User avatar
mcdikki
 
Posts: 1059
Joined: 11 Dec 2012, 15:48
Location: Germany

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 15:14

Yes, I've read the protocol reference lots of times, but there's a key part missing. I don't like to waste people's time so I Googled (and Binged and DuckduckGo'ed) but what I found was lots of other people with exactly the same problem of needing the actual code to get the xml bit to CasparCG from Livecode.

Look around - the same question gets asked over and over and people reply saying - with all due respect -

"you don't need much more than this page and some knowledge how to use socket networking in live code to get your client running."

The socket bit is easy - but I can't make it work and neither can they. There is presumably a way of setting up the string in LiveCode that actually works, or a workaround that puts the data into the server first. Lots of people, especially me, would like to know, then a simple Google question would save huge amounts of time.

Oh - and please see above what happened when I used the official example as a data file run from the Caspar console.

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby didikunz » 02 Aug 2016, 15:40

The thing is, that mcdikki and I cannot help you, as we are prgamming in dotNET and not in LiveCode. I know, that for instance emisiona has a a twitter client made in LiveCode, so you probably can ask him for a code snippet on how to assemble the XML string. See here for details: http://casparcg.com/forum/viewtopic.php?f=5&t=2683&p=25847&hilit=LiveCode#p25847
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 15:46

Thank you . I understand that you're trying to help, but you're elsewhere. I was rather hoping that someone who does know will read and reply. I've put a similar request on the Livecode forum.

And you'll see from the topic reference that you've quoted that I'm not the only one, and that the person asking hasn't had a reply from anyone.

thanks again

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby mcdikki » 02 Aug 2016, 16:07

Your problem is not casparCG or it's commands, it handling strings in livecode.
So, my statement that the wiki and socket programming is enough is correct. String manipulation is so basic that one can expect it to work in every programming language.

But since this seems to be the issue, I would do livecode related searches and ask in livecode forums instead of here. We will be able to help you in ccg related topics mainly. Everything else is just luck ;-)

A quick search gives me some interesting links according to escaping strings:
http://www.rozek.mobi/LiveCode/BasicLib ... cr_de.html (lib with escapte functions)
https://gist.github.com/trevordevore/5584753 (A livecode xml converter)
... and many more.

Cheers
mcdikki
sublan.tv - Wir teilen Begeisterung
User avatar
mcdikki
 
Posts: 1059
Joined: 11 Dec 2012, 15:48
Location: Germany

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 20:59

Yes, you are indeed right - it's string handling that's the problem. I've seen a number of similar requests here so I started here, but I also asked asked on the Livecode forum with the string from the example -

Code: Select all
CG 1 ADD 0 "demo/test" 1 "<templateData><componentData id="f0"><data id="text" value="Niklas P Andersson"></data> </componentData><componentData id="f1"><data id="text" value="developer"></data></componentData><componentData id="f2"><data id="text" value="Providing an example"></data> </componentData></templateData>

- which was translated to -

Code: Select all
put format("CG 1 ADD 0 \"demo/test\" 1 \"<templateData><componentData id=\"f0\"><data id=\"text\" value=\"Niklas P Andersson\"></data> </componentData><componentData id=\"f1\"><data id=\"text\" value=\"developer\"></data></componentData><componentData id=\"f2\"><data id=\"text\" value=\"Providing an example\"></data> </componentData></templateData>") into tCode


I haven't seen "format" mentioned before in this context, but for the first time Livecode hasn't thrown a wobbly - though CasparCG didn't like the result. I fiddled with the CG code a bit but it didn't like that either - error 1090. Needs research probably -

Code: Select all
CG 1 ADD 20 "lower2" 1 "<templateData><componentData id="f0"><data id="text" value="Niklas P Andersson"></data> </componentData><componentData id="f1"><data id="text" value="developer"></data></componentData></templateData>\r\n
[2016-08-02 20:31:39.662] [7292]  [info]    flash[cg20.fth.pal|5000] Invoking add-command: <invoke name="Add" returntype="xml"><arguments><number>20</number><string>LOWER2.ft</string><true/><string></string><string><![CDATA[ <templateData><componentData id=]]></string></arguments></invoke>
[2016-08-02 20:31:39.663] [7796]  [debug]   flash-player[cg20.fth.pal|1024x576] [command]      <invoke name="OnCommand" returntype="xml"><arguments><string>Command recieved @Add@20@</string></arguments></invoke>
[2016-08-02 20:31:39.663] [7796]  [warning] flash-player[cg20.fth.pal|1024x576] Flash call failed:<exception>TypeError: Error #1090</exception>
[2016-08-02 20:31:39.663] [5032]  [debug]   Executed command: CGCommand
[2016-08-02 20:31:39.663] [5032]  [info]    Sent message to 127.0.0.1: 202 CG OK\r\n


Did I get the CG ADD bit wrong?

B

[Edit by mcdikki] I added codetags. Please use them instead of coloring for code as they are much better to read. Thanks.
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby bern333 » 02 Aug 2016, 21:04

...or did the format function take out the escape codes that I need at the CCG end?

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby mcdikki » 02 Aug 2016, 23:18

The type mismatch error indicates that the template my be wrong or the data send to the template is wrong (e.g. set a field that expects a number to a string).

The call looks ok so far. I would compare the console log from ccg when you send the command by the svt client and when you send it from livecode. They should be the same.

Cheers
mcdikki

PS: I don't know if it is a good idea to escape the whole command string with format. I would only escape the xml part.
sublan.tv - Wir teilen Begeisterung
User avatar
mcdikki
 
Posts: 1059
Joined: 11 Dec 2012, 15:48
Location: Germany

Re: Please - a simple basic tutorial

Postby bern333 » 03 Aug 2016, 09:16

Sadly that didn't work. The string has to arrive at CasparCG with the escapes intact.

This from the CCG log when sent by the supplied CCG client (not suitable for this task otherwise I'd use it) -

Code: Select all
CG 1-20 ADD 1 "LOWER2" 1 "<templateData><componentData id=\"f0\"><data id=\"text\" value=\"bern\"/></componentData><componentData id=\"f1\"><data id=\"text\" value=\"boss\"/></componentData></templateData>"\r\n


This from Livecode using the "format" method as suggested on the Livecode forum-

Code: Select all
CG 1-20 ADD 1 "lower2" 1 "<templateData><componentData id="f0"><data id="text" value="bern"></data> </componentData><componentData id="f1"><data id="text" value="boss"></data></componentData></templateData>\r\n


Flash sends a 1090 error because (I assume) it didn't get the escape codes. I've gone back to the Livecode forum with the problem, but any thoughts from anybody extremely welcome

Thanks
Bernie
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby didikunz » 03 Aug 2016, 10:16

As I told earlier, I don't know LiveCode. But I would try to find a function, that searches and replace inside a text-string. You then serach for " and replace with \" It's a bit of a hack, but should do it.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: Please - a simple basic tutorial

Postby mcdikki » 03 Aug 2016, 14:42

As I told you, split your command into two parts:
1. the command
Code: Select all
CG 1-20 ADD 1 "lower2" 1

2. the xml data
Code: Select all
"<templateData><componentData id="f0"><data id="text" value="bern"></data> </componentData><componentData id="f1"><data id="text" value="boss"></data></componentData></templateData>


Now, what is the problem replacing all the " with \" in the xml data?
A short googlesearch gives me this: http://lessons.livecode.com/m/4603/l/56 ... -with-text
Code: Select all
replace "at" with "XX" in field "text"

So something like this should do it (I don't know livecode at all):
Code: Select all
put "CG 1-20 ADD 1 \"lower2\" 1 " in command
put "<templateData><componentData id='f0'><data id='text' value='bern'></data> </componentData><componentData id='f1'><data id='text' value='boss'></data></componentData></templateData>" in xmldata
replace "'" with "\\\"" in xmldata
...
// send command + xmldata + "\r\n" //


cheers mcdikki
sublan.tv - Wir teilen Begeisterung
User avatar
mcdikki
 
Posts: 1059
Joined: 11 Dec 2012, 15:48
Location: Germany

Re: Please - a simple basic tutorial

Postby bern333 » 03 Aug 2016, 21:50

From the Livecode forum I have the answer , from a lady called Jacqueline Landman Gay who is big in the LC community.

This is for others who stagger through here looking for the same thing -

Put a known, working, command and escaped xml string into a hidden field on the card as a template eg -

Code: Select all
CG 1-20 ADD 1 "LOWER2" 1 "<templateData><componentData id=\"f0\"><data id=\"text\" value=\"xxxxx\"/></componentData><componentData id=\"f1\"><data id=\"text\" value=\"yyyyy\"/></componentData></templateData>"


Use string replacement to change the command or the data within the xml to what you need, and write the field to the socket -

Code: Select all
   replace "xxxxx" with "bern" in field "template"
   replace "yyyyy" with "boss" in field "template"

   write  field "template" & format("\r\n") to socket "127.0.0.1:5250"   


Done, and many hours of angst over

EDIT - slight update - you need two hidden fields because when you insert the data it stays that way, so you have to refresh from another clean copy.

B
bern333
 
Posts: 23
Joined: 14 Jul 2016, 09:44

Re: Please - a simple basic tutorial

Postby laroca » 08 Mar 2017, 14:07

Hi, i really want to thanks to this post becouse make me the life so easy in the develop of my own client. And just take to me just a couple of hours to understand it. I make a post with the development of the proyect. Bern333, please send my thanks to Jackeline for help us.
laroca
 
Posts: 15
Joined: 30 Mar 2016, 19:25


Return to General discussions

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests